11#define DNA_DEPRECATED_ALLOW
102 std::optional<Library *> ,
107 ParticleSettings *particle_settings_dst = id_cast<ParticleSettings *>(id_dst);
108 const ParticleSettings *partticle_settings_src = id_cast<const ParticleSettings *>(id_src);
115 MEM_dupalloc(partticle_settings_src->
fluid));
129 for (
int a = 0; a <
MAX_MTEX; a++) {
130 if (partticle_settings_src->
mtex[a]) {
131 particle_settings_dst->
mtex[a] =
static_cast<MTex *
>(
132 MEM_dupalloc(partticle_settings_src->
mtex[a]));
144 for (
int a = 0; a <
MAX_MTEX; a++) {
145 MEM_SAFE_DELETE(particle_settings->
mtex[a]);
179 for (
int i = 0; i <
MAX_MTEX; i++) {
180 if (psett->
mtex[i]) {
251 BoidCondition *cond =
state->conditions.first();
252 for (; cond; cond = cond->next) {
282 if (dw.
ob !=
nullptr) {
286 if (
object == dw.
ob) {
308 for (
int a = 0; a <
MAX_MTEX; a++) {
380 return std::max(boid_rule_struct_size(rule.type), sizeof(BoidRule));
396 for (
int a = 0; a <
MAX_MTEX; a++) {
414 .id_code = ParticleSettings::id_type,
419 .name =
"ParticleSettings",
420 .name_plural =
N_(
"particles"),
423 .asset_type_info =
nullptr,
428 .make_local =
nullptr,
430 .foreach_cache =
nullptr,
431 .foreach_path =
nullptr,
432 .foreach_working_space_color =
nullptr,
433 .foreach_asset_weak_reference =
nullptr,
434 .owner_pointer_get =
nullptr,
440 .blend_read_undo_preserve =
nullptr,
442 .lib_override_apply_post =
nullptr,
461 ParticleThreadContext *ctx,
467 ParticleTexture *ptex);
470 ParticleSettings *part,
476 ParticleTexture *ptex,
510 else if (p % totgr == cur) {
519#define PATH_CACHE_BUF_SIZE 1024
532 int i, totkey, totbufkey;
534 tot = std::max(tot, 1);
538 while (totkey < tot) {
544 for (i = 0; i < totbufkey; i++) {
564 bufs->free_no_destruct();
629 Object *lattice =
nullptr;
634 for (; md; md = md->
next) {
636 if (md->
mode & mode) {
676 for (; psys; psys = psys->
next) {
684 for (; psys; psys = psys->
next) {
700 if (object_eval ==
object) {
704 while (psys_eval !=
nullptr) {
708 psys_eval = psys_eval->
next;
727 if (
object ==
nullptr) {
753 if (use_render_params) {
779 ListBaseT<Base> instance_collection_objects = {
nullptr,
nullptr};
786 if (dw.
ob ==
nullptr) {
788 if (base !=
nullptr) {
810 if (dw->
ob ==
nullptr ||
826 while (dw && dw->
ob !=
object) {
831 dw = MEM_new<ParticleDupliWeight>(
"ParticleDupliWeight");
883 MEM_SAFE_DELETE(pa->hair);
892 psys->
clmd =
nullptr;
956 MEM_delete(psys->
child);
957 psys->
child =
nullptr;
975 MEM_delete(pa->hair);
1028 if (psys->
clmd !=
nullptr) {
1039 MEM_delete(psys->
child);
1040 psys->
child =
nullptr;
1058 psys->
part =
nullptr;
1065 psys->
targets.free_no_destruct();
1078 MEM_delete(psys->
pdd);
1101 psys_dst->
child = MEM_dupalloc(psys_src->
child);
1125 for (p = 0, pa = psys_dst->
particles; p < psys_dst->totpart; p++, pa++) {
1134 if (key !=
nullptr) {
1135 key = MEM_dupalloc(key);
1137 if (boid !=
nullptr) {
1138 boid = MEM_dupalloc(boid);
1140 for (p = 0, pa = psys_dst->
particles; p < psys_dst->totpart; p++, pa++) {
1141 if (boid !=
nullptr) {
1144 if (key !=
nullptr) {
1159 float v1,
float v2,
float v3,
float v4,
const float w[4],
int four)
1163 value =
w[0] * v1 +
w[1] *
v2 +
w[2] * v3;
1168 CLAMP(value, 0.0f, 1.0f);
1244 *cur = (*cur)->
next;
1249 while (*cur && (*cur)->
next &&
float((*cur)->frame) < t) {
1250 *cur = (*cur)->
next;
1289 *r_start = pm.
frame;
1298 *r_dietime = pm.
frame + 1;
1309 int dietime = 10000000;
1314 dietime = pm.frame + 1;
1319 return float(dietime);
1337 else if (pind->
keyed) {
1339 pind->
kkey[0] = key;
1340 pind->
kkey[1] = pa->
totkey > 1 ? key + 1 :
nullptr;
1345 else if (pind->
cache) {
1346 float start = 0.0f, dietime = 0.0f;
1358 pind->
hkey[0] = key;
1359 pind->
hkey[1] = key + 1;
1365 float3 *positions = pind->
mesh->vert_positions_for_write().data();
1399 int point_vel = (point && point->
keys->
vel);
1400 float real_t, dfra, keytime, invdt = 1.0f;
1407 if (
result->time < 0.0f) {
1415 while (*(pind->
ekey[1]->
time) < real_t) {
1421 else if (pind->
keyed) {
1423 if (pind->
kkey[1] ==
nullptr) {
1428 if (
result->time < 0.0f) {
1441 while (pt && pa->
time + pt->
time < real_t) {
1459 while (pind->
kkey[1]->
time < real_t) {
1465 else if (pind->
cache) {
1466 if (
result->time < 0.0f) {
1474 if (
result->time < 0.0f) {
1482 while (pind->
hkey[1]->
time < real_t) {
1497 else if (pind->
mesh) {
1502 else if (pind->
keyed) {
1506 else if (pind->
cache) {
1515 if (!pind->
keyed && !pind->
cache && !point_vel) {
1517 if (pind->
ekey[0] != point->
keys) {
1524 else if (pind->
mesh) {
1549 else if (pind->
mesh) {
1567 dfra = keys[2].
time - keys[1].
time;
1568 keytime = (real_t - keys[1].
time) / dfra;
1571 if (pind->
keyed || pind->
cache || point_vel) {
1572 invdt = dfra * 0.04f * (psys ? psys->
part->
timetweak : 1.0f);
1590 if (pind->
keyed || pind->
cache || point_vel) {
1601 t *= (first + first->
segments)->time;
1603 while (i < first->segments && cur->
time < t) {
1607 if (cur->
time == t) {
1611 float dt = (t - (cur - 1)->time) / (cur->
time - (cur - 1)->time);
1619 if (cur == first || cur - 1 == first) {
1634 const float (*vert_positions)[3],
1635 const float (*vert_normals)[3],
1638 const float (*orcodata)[3],
1646 const float *v1 =
nullptr, *
v2 =
nullptr, *v3 =
nullptr, *v4 =
nullptr;
1647 float e1[3], e2[3], s1, s2, t1, t2;
1648 float *uv1, *uv2, *uv3, *uv4;
1649 float n1[3], n2[3], n3[3], n4[3];
1651 const float *o1, *o2, *o3, *o4;
1653 v1 = vert_positions[mface->
v1];
1654 v2 = vert_positions[mface->
v2];
1655 v3 = vert_positions[mface->
v3];
1662 v4 = vert_positions[mface->
v4];
1668 if (mface->
flag & ME_SMOOTH) {
1680 if (mface->
flag & ME_SMOOTH) {
1711 s1 = uv3[0] - uv1[0];
1712 s2 = uv4[0] - uv1[0];
1714 t1 = uv3[1] - uv1[1];
1715 t2 = uv4[1] - uv1[1];
1721 s1 = uv2[0] - uv1[0];
1722 s2 = uv3[0] - uv1[0];
1724 t1 = uv2[1] - uv1[1];
1725 t2 = uv3[1] - uv1[1];
1731 vtan[0] = (s1 * e2[0] - s2 * e1[0]);
1732 vtan[1] = (s1 * e2[1] - s2 * e1[1]);
1733 vtan[2] = (s1 * e2[2] - s2 * e1[2]);
1735 utan[0] = (t1 * e2[0] - t2 * e1[0]);
1736 utan[1] = (t1 * e2[1] - t2 * e1[1]);
1737 utan[2] = (t1 * e2[2] - t2 * e1[2]);
1742 o1 = orcodata[mface->
v1];
1743 o2 = orcodata[mface->
v2];
1744 o3 = orcodata[mface->
v3];
1747 o4 = orcodata[mface->
v4];
1763 float v10 = tface->
uv[0][0];
1764 float v11 = tface->
uv[0][1];
1765 float v20 = tface->
uv[1][0];
1766 float v21 = tface->
uv[1][1];
1767 float v30 = tface->
uv[2][0];
1768 float v31 = tface->
uv[2][1];
1772 v40 = tface->
uv[3][0];
1773 v41 = tface->
uv[3][1];
1775 r_uv[0] =
w[0] * v10 +
w[1] * v20 +
w[2] * v30 +
w[3] * v40;
1776 r_uv[1] =
w[0] * v11 +
w[1] * v21 +
w[2] * v31 +
w[3] * v41;
1779 r_uv[0] =
w[0] * v10 +
w[1] * v20 +
w[2] * v30;
1780 r_uv[1] =
w[0] * v11 +
w[1] * v21 +
w[2] * v31;
1786 const char *cp1, *cp2, *cp3, *cp4;
1789 cp =
reinterpret_cast<char *
>(mc);
1790 cp1 =
reinterpret_cast<const char *
>(&mcol[0]);
1791 cp2 =
reinterpret_cast<const char *
>(&mcol[1]);
1792 cp3 =
reinterpret_cast<const char *
>(&mcol[2]);
1795 cp4 =
reinterpret_cast<char *
>(
const_cast<MCol *
>(&mcol[3]));
1797 cp[0] = int(
w[0] * cp1[0] +
w[1] * cp2[0] +
w[2] * cp3[0] +
w[3] * cp4[0]);
1798 cp[1] = int(
w[0] * cp1[1] +
w[1] * cp2[1] +
w[2] * cp3[1] +
w[3] * cp4[1]);
1799 cp[2] = int(
w[0] * cp1[2] +
w[1] * cp2[2] +
w[2] * cp3[2] +
w[3] * cp4[2]);
1800 cp[3] = int(
w[0] * cp1[3] +
w[1] * cp2[3] +
w[2] * cp3[3] +
w[3] * cp4[3]);
1803 cp[0] = int(
w[0] * cp1[0] +
w[1] * cp2[0] +
w[2] * cp3[0]);
1804 cp[1] = int(
w[0] * cp1[1] +
w[1] * cp2[1] +
w[2] * cp3[1]);
1805 cp[2] = int(
w[0] * cp1[2] +
w[1] * cp2[2] +
w[2] * cp3[2]);
1806 cp[3] = int(
w[0] * cp1[3] +
w[1] * cp2[3] +
w[2] * cp3[3]);
1811 Mesh *
mesh,
short from,
int index,
const float fw[4],
const float *values)
1813 if (values ==
nullptr ||
index == -1) {
1819 return values[
index];
1826 values[mf->
v1], values[mf->
v2], values[mf->
v3], values[mf->
v4], fw, mf->
v4);
1835 uv[0] =
w[1] +
w[2];
1836 uv[1] =
w[2] +
w[3];
1842 float v[4][3], co[3];
1844 v[0][0] = osface->
uv[0][0];
1845 v[0][1] = osface->
uv[0][1];
1847 v[1][0] = osface->
uv[1][0];
1848 v[1][1] = osface->
uv[1][1];
1850 v[2][0] = osface->
uv[2][0];
1851 v[2][1] = osface->
uv[2][1];
1858 v[3][0] = osface->
uv[3][0];
1859 v[3][1] = osface->
uv[3][1];
1870 Mesh *mesh_original,
1875 MFace *mtessface_final;
1879 const float (*faceuv)[2];
1881 const int *index_mf_to_mpoly_deformed =
nullptr;
1882 const int *index_mf_to_mpoly =
nullptr;
1883 const int *index_mp_to_orig =
nullptr;
1886 const int totface_deformed = mesh_original ? mesh_original->
totface_legacy : totface_final;
1888 if (
ELEM(0, totface_final, totface_deformed)) {
1892 index_mf_to_mpoly =
static_cast<const int *
>(
1894 index_mp_to_orig =
static_cast<const int *
>(
1898 if (mesh_original) {
1899 index_mf_to_mpoly_deformed =
static_cast<const int *
>(
1904 index_mf_to_mpoly_deformed = index_mf_to_mpoly;
1908 pindex_orig = index_mf_to_mpoly_deformed[findex_orig];
1910 if (mesh_original ==
nullptr) {
1911 mesh_original = mesh_final;
1914 index_mf_to_mpoly_deformed =
nullptr;
1921 if (osface_final ==
nullptr) {
1923 if (findex_orig < totface_final) {
1928 printf(
"\tNO CD_ORIGSPACE, error out of range\n");
1939 LinkNode *tessface_node = poly_nodes[pindex_orig];
1941 for (; tessface_node; tessface_node = tessface_node->
next) {
1943 faceuv = osface_final[findex_dst].
uv;
1947 if (mtessface_final[findex_dst].v4) {
1958 for (
int findex_dst = 0; findex_dst < totface_final; findex_dst++) {
1964 faceuv = osface_final[findex_dst].
uv;
1968 if (mtessface_final[findex_dst].v4) {
2024 *mapindex = index_dmcache;
2028 int i = index_dmcache;
2040 const MFace *mfaces =
static_cast<const MFace *
>(
2042 const MFace *mface = &mfaces[i];
2044 if (osface ==
nullptr) {
2045 mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f;
2068 float tmpnor[3], mapfw[4];
2069 const float (*orcodata)[3];
2075 vec[0] = vec[1] = vec[2] = 0.0;
2078 nor[0] = nor[1] = 0.0;
2082 orco[0] = orco[1] = orco[2] = 0.0;
2085 utan[0] = utan[1] = utan[2] = 0.0;
2088 vtan[0] = vtan[1] = vtan[2] = 0.0;
2094 orcodata =
static_cast<const float (*)[3]
>(
2096 const Span<float3> vert_normals = mesh_final->vert_normals();
2099 const Span<float3> vert_positions = mesh_final->vert_positions();
2117 utan[0] = utan[1] = utan[2] = 0.0f;
2118 vtan[0] = vtan[1] = vtan[2] = 0.0f;
2127 mface = &mfaces[mapindex];
2128 const Span<float3> vert_positions = mesh_final->vert_positions();
2138 reinterpret_cast<const float (*)[3]
>(vert_positions.
data()),
2139 reinterpret_cast<const float (*)[3]
>(vert_normals.
data()),
2161 reinterpret_cast<const float (*)[3]
>(vert_positions.
data()),
2162 reinterpret_cast<const float (*)[3]
>(vert_normals.
data()),
2197 if (psmd->
psys == psys) {
2222 const float zerovec[3] = {0.0f, 0.0f, 0.0f};
2310 psmd->
mesh_final, from,
index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
2361 if (!eff.guide_data) {
2363 "GuideEffectorData");
2366 data = eff.guide_data + p;
2380 ListBaseT<EffectorCache> *effectors,
2393 float effect[3] = {0.0f, 0.0f, 0.0f}, veffect[3] = {0.0f, 0.0f, 0.0f};
2394 float guidevec[4], guidedir[3], rot2[4], temp[3];
2395 float guidetime, radius, weight,
angle, totstrength = 0.0f;
2396 float vec_to_point[3];
2408 if (
data->strength <= 0.0f) {
2412 guidetime = time / (1.0f - pd->
free_end);
2414 if (guidetime > 1.0f) {
2418 cu = id_cast<Curve *>(eff.ob->data);
2422 data->strength * guidetime,
2433 if (
BKE_where_on_path(eff.ob, guidetime, guidevec, guidedir,
nullptr, &radius, &weight) ==
2440 mul_m4_v3(eff.ob->object_to_world().ptr(), guidevec);
2447 if (guidetime != 0.0f) {
2466 int(
data->strength * guidetime * 100.0f),
2484 const float par_co[3] = {0.0f, 0.0f, 0.0f};
2485 const float par_vel[3] = {0.0f, 0.0f, 0.0f};
2486 const float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
2487 const float orco_offset[3] = {0.0f, 0.0f, 0.0f};
2521 totstrength +=
data->strength;
2524 totstrength *= weight;
2529 if (totstrength != 0.0f) {
2530 if (totstrength > 1.0f) {
2533 CLAMP(totstrength, 0.0f, 1.0f);
2557 float force[3] = {0.0f, 0.0f, 0.0f};
2623 float *vg =
nullptr;
2628 else if (psys->
vgroup[vgroup]) {
2631 int totvert =
mesh->verts_num, i;
2633 if (psys->
vg_neg & (1 << vgroup)) {
2634 for (i = 0; i < totvert; i++) {
2639 for (i = 0; i < totvert; i++) {
2655 float co[3], orco[3];
2657 totparent = int(totchild * part->
parents * 0.3f);
2664 totparent = std::min(sim->
psys->
totpart, totparent);
2668 for (p = 0, cpa = sim->
psys->
child; p < totparent; p++, cpa++) {
2702 for (; p < totchild; p++, cpa++) {
2724 const bool editupdate,
2725 const bool use_render_params)
2729 int totparent = 0, between = 0;
2739 if ((use_render_params == 0) &&
2749 totparent = int(totchild * part->
parents * 0.3f);
2759 if (use_render_params) {
2763 totchild = int(
float(totchild) *
float(part->
disp) / 100.0f);
2766 totparent = std::min(totparent, totchild);
2768 if (totchild == 0) {
2830 int seed = 31415926 + sim->
psys->
seed;
2852 float *cpa_fuv =
nullptr, *par_rot =
nullptr,
rot[4];
2853 float orco[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3];
2854 float eff_length, eff_vec[3], weight[4];
2865 float foffset, wsum = 0.0f;
2887 memset(child_keys, 0,
sizeof(*child_keys) * (ctx->
segments + 1));
2891 for (
w = 0;
w < 4;
w++) {
2892 if (cpa->
pa[
w] >= 0) {
2893 key[
w] = pcache[cpa->
pa[
w]];
2894 weight[
w] = cpa->
w[
w];
2905 for (
w = 0;
w < 4;
w++) {
2906 if (
w && (weight[
w] > 0.0f)) {
2912 float d1 =
len_v3v3(key[0]->co, key[
w]->co);
2915 d = d1 > 0.0f ? d2 / d1 - 1.0f : 10000.0f;
2927 if (p_max > p_min) {
2928 d = (d - p_min) / (p_max - p_min);
2931 d = (d - p_min) <= 0.0f ? 0.0f : 1.0f;
2934 CLAMP(d, 0.0f, 1.0f);
2937 weight[
w] *= (1.0f - d);
2942 for (
w = 0;
w < 4;
w++) {
2968 mul_m4_v3(ob->object_to_world().ptr(), co);
2970 for (
w = 0;
w < 4;
w++) {
2984 memset(child_keys, 0,
sizeof(*child_keys) * (ctx->
segments + 1));
2988 key[0] = pcache[cpa->
parent];
2991 cpa_from = part->
from;
3035 for (k = 0, child = child_keys; k <= ctx->
segments; k++, child++) {
3043 for (
w = 0;
w < 4;
w++) {
3077 par_rot = key[0]->
rot;
3093 for (k = 0, child = child_keys; k <= ctx->
segments; k++, child++) {
3109 eff_length =
len_v3(eff_vec);
3125 par = cache[cpa->
parent];
3128 else if (cpa->
parent >= 0) {
3130 par = pcache[cpa->
parent];
3135 if (cpa->
pa[k] >= 0) {
3137 par = pcache[cpa->
pa[k]];
3147 ListBaseT<ModifierData> modifiers;
3148 modifiers.clear_no_delete();
3163 ctx, &modifiers, cpa, &ptex, orco, hairmat, child_keys, par, par_orco);
3171 if (i < ctx->totparent) {
3186 for (i = task->
begin; i < task->end; i++, cpa++) {
3194 const bool editupdate,
3195 const bool use_render_params)
3253 float *prev_tangent,
3256 float cosangle,
angle, tangent[3], normal[3], q[4];
3272 cosangle =
dot_v3v3(tangent, prev_tangent);
3277 if (cosangle > 0.999999f) {
3311 float birthtime = 0.0, dietime = 0.0;
3312 float t, time = 0.0, dfra = 1.0;
3313 float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
3314 float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4];
3320 float *vg_effector =
nullptr;
3321 float *vg_length =
nullptr, pa_length = 1.0f;
3379 pind.
mesh = hair_mesh;
3381 memset(cache[p], 0,
sizeof(*cache[p]) * (segments + 1));
3404 if (birthtime >= dietime) {
3409 dietime = birthtime + pa_length * (dietime - birthtime);
3412 for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
3414 t = birthtime + time * (dietime - birthtime);
3434 for (k = 0, hkey = pa->hair; k < pa->totkey; k++, hkey++) {
3444 float effector = 1.0f;
3447 psmd->mesh_final, psys->
part->
from, pa, vg_effector);
3450 sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co);
3453 for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
3455 sim, p, ca, k, segments, cache[p]->co, effector, dfra, cfra, &
length, vec);
3461 for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
3468 float(k) /
float(segments));
3475 for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
3483 for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
3486 if (k == segments) {
3514 MEM_delete(vg_effector);
3518 MEM_delete(vg_length);
3541 if (point->
totkey == 0) {
3550 const int segments = iter_data->
segments;
3551 const bool use_weight = iter_data->
use_weight;
3553 float birthtime = 0.0f, dietime = 0.0f;
3554 float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f};
3558 pind.
cache =
nullptr;
3561 pind.
mesh =
nullptr;
3565 pind.
hkey[0] =
nullptr;
3571 memset(cache[iter], 0,
sizeof(*cache[iter]) * (segments + 1));
3588 if (birthtime >= dietime) {
3596 float t, time = 0.0f, keytime = 0.0f;
3597 for (k = 0, ca = cache[iter]; k <= segments; k++, ca++) {
3599 t = birthtime + time * (dietime - birthtime);
3612 if (k == segments) {
3625 ca->
vel[0] = ca->
vel[1] = 0.0f;
3637 if (
result.time < 0.0f) {
3645 while (pind.
hkey[1]->
time < real_t) {
3669 ca->
col[0] = 1.0f - keytime;
3675 ca->
col[0] = keytime;
3702 const bool use_render_params)
3712 int totpart = edit->
totpoint, recalc_set = 0;
3718 segments = std::max(segments, 4);
3728 for (i = 0, point = edit->
points; i < totpart; i++, point++) {
3739 iter_data.
edit = edit;
3766 for (i = 0, point = edit->
points; i < totpart; i++, point++) {
3784 float to_time = to->
time;
3805static void triatomat(
float *v1,
float *
v2,
float *v3,
const float (*uv)[2],
float mat[4][4])
3807 float det, w1, w2, d1[2], d2[2];
3809 memset(mat, 0,
sizeof(
float[4][4]));
3817 d1[0] = uv[1][0] - uv[0][0];
3818 d1[1] = uv[1][1] - uv[0][1];
3819 d2[0] = uv[2][0] - uv[0][0];
3820 d2[1] = uv[2][1] - uv[0][1];
3822 det = d2[0] * d1[1] - d2[1] * d1[0];
3829 mat[1][0] = w1 * (
v2[0] - v1[0]) + w2 * (v3[0] - v1[0]);
3830 mat[1][1] = w1 * (
v2[1] - v1[1]) + w2 * (v3[1] - v1[1]);
3831 mat[1][2] = w1 * (
v2[2] - v1[2]) + w2 * (v3[2] - v1[2]);
3835 mat[1][0] = mat[1][1] = mat[1][2] = 0.0f;
3851 const float (*orcodata)[3];
3854 if (i == -1 || i >=
mesh->totface_legacy) {
3865 if (orco && (orcodata =
static_cast<const float (*)[3]
>(
3885 triatomat(
v[0],
v[1],
v[2], (osface) ? osface->
uv :
nullptr, mat);
3917 float vec[3], orco[3];
3947 float facemat[4][4];
3951 mul_m4_m4m4(hairmat, ob->object_to_world().ptr(), facemat);
3971 if (name ==
nullptr) {
3972 name = (psys_orig !=
nullptr) ? psys_orig->
name :
DATA_(
"ParticleSystem");
3976 for (; psys; psys = psys->
next) {
3980 psys = MEM_new<ParticleSystem>(
"particle_system");
3985 if (psys_orig !=
nullptr) {
4005 if (scene !=
nullptr) {
4206 tf =
static_cast<const MTFace *
>(
4208 if (tf ==
nullptr) {
4211 if (tf ==
nullptr) {
4217 if ((!from_vert && i >=
mesh->totface_legacy) || (from_vert && i >=
mesh->verts_num)) {
4237 for (
int j = 0; j <
mesh->totface_legacy; j++, mf++) {
4250 texco[0] = texco[0] * 2.0f - 1.0f;
4251 texco[1] = texco[1] * 2.0f - 1.0f;
4258#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \
4259 if ((event & mtex->mapto) & type) { \
4260 pvalue = texture_value_blend(def, pvalue, value, texfac, blend); \
4264#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \
4265 if (event & type) { \
4266 CLAMP(pvalue, 0.0f, 1.0f); \
4270#define CLAMP_WARP_PARTICLE_TEXTURE_POS(type, pvalue) \
4271 if (event & type) { \
4272 if (pvalue < 0.0f) { \
4273 pvalue = 1.0f + pvalue; \
4275 CLAMP(pvalue, 0.0f, 1.0f); \
4279#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) \
4280 if (event & type) { \
4281 CLAMP(pvalue, -1.0f, 1.0f); \
4299 float value, rgba[4], texvec[3];
4309 for (m = 0; m <
MAX_MTEX; m++, mtexp++) {
4311 if (mtex && mtex->
tex && mtex->
mapto) {
4314 short texco = mtex->
texco;
4351 texvec[0] = 2.0f * (cfra - par->
time) / (par->
dietime - par->
time) - 1.0f;
4389 float value, rgba[4], co[3], texvec[3];
4400 for (m = 0; m <
MAX_MTEX; m++, mtexp++) {
4402 if (mtex && mtex->
tex && mtex->
mapto) {
4405 short texco = mtex->
texco;
4451 if (
mesh->texspace_size[0] != 0.0f) {
4452 texvec[0] /=
mesh->texspace_size[0];
4454 if (
mesh->texspace_size[1] != 0.0f) {
4455 texvec[1] /=
mesh->texspace_size[1];
4457 if (
mesh->texspace_size[2] != 0.0f) {
4458 texvec[2] /=
mesh->texspace_size[2];
4463 texvec[0] = 2.0f * (cfra - pa->
time) / (pa->
dietime - pa->
time) - 1.0f;
4479 int flip = (mtex->
timefac < 0.0f);
4481 ptex->
time *= 1.0f - timefac;
4482 ptex->
time += timefac * ((flip) ? 1.0f - value : value);
4549 *dietime = time + life;
4552 return (cfra - time) / life;
4592 int i = cpa - psys->
child;
4620 ctx->
mesh, cpa_from, cpa_num, cpa_fuv, ctx->
vg_kink);
4660 float co[3], orco[3];
4661 float hairmat[4][4];
4664 short between = 0, edit = 0;
4677 CLAMP(t, 0.0f, 1.0f);
4728 else if (totchild) {
4740 float par_co[3], par_orco[3];
4742 cpa = psys->
child + p - totpart;
4744 if (
state->time < 0.0f) {
4818 cpa_from = part->
from;
4856 ctx.
mesh = psmd->mesh_final;
4895 modifier_ctx.
sim = sim;
4896 modifier_ctx.
ptex = &ptex;
4897 modifier_ctx.
cpa = cpa;
4898 modifier_ctx.
orco = orco;
4912 tstate_tmp.
time = t - 0.001f;
4918 tstate_tmp.
time = t + 0.001f;
4956 cpa = psys->
child + p - totpart;
4991 cfra = std::min(cfra, pa->
dietime);
4995 state->time = -cfra;
5004 const float par_orco[3] = {0.0f, 0.0f, 0.0f};
5009 CLAMP(t, 0.0f, 1.0f);
5014 modifier_ctx.
sim = sim;
5015 modifier_ctx.
ptex =
nullptr;
5016 modifier_ctx.
cpa = cpa;
5058 dfra = keys[2].
time - keys[1].
time;
5060 keytime = (
state->time - keys[1].
time) / dfra;
5063 mul_v3_fl(keys[1].vel, dfra * timestep);
5064 mul_v3_fl(keys[2].vel, dfra * timestep);
5119 uv[0] = uv[1] = 0.0f;
5133 if (mtface !=
nullptr) {
5134 const MFace *mface =
static_cast<const MFace *
>(
5213 float loc[3], nor[3], vec[3], side[3],
len;
5214 float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3];
5219 if (pa ==
nullptr) {
5297 float hairmat[4][4], imat[4][4];
5299 for (p = 0; p < psys->
totpart; p++, pa++) {
5304 for (h = 0; h < pa->
totkey; h++, hkey++) {
5332 if (particlesystem ==
nullptr) {
5336 part = particlesystem->
part;
5341 if (part ==
nullptr || pars ==
nullptr) {
5354 if (particle_no < totpart && particlesystem->pathcache) {
5355 cache = particlesystem->
pathcache[particle_no];
5358 else if (particle_no < totpart + totchild && particlesystem->childcache) {
5359 cache = particlesystem->
childcache[particle_no - totpart];
5395 totface =
modifier->mesh_final->totface_legacy;
5396 totvert =
modifier->mesh_final->verts_num;
5399 if (!particlesystem || !totface) {
5403 part = particlesystem->
part;
5414 if (particle_no >= totpart + totchild) {
5419 if (particle_no < totpart) {
5425 *r_fuv = &particle->
fuv;
5431 const MFace *mface =
static_cast<const MFace *
>(
5434 *r_fuv = &particle->
fuv;
5439 for (
int i = 0; i < totface; i++, mface++) {
5469 *r_fuv = &parent->
fuv;
5475 const MFace *mface =
static_cast<const MFace *
>(
5478 *r_fuv = &parent->
fuv;
5483 for (
int i = 0; i < totface; i++, mface++) {
5504 if (
modifier->mesh_final ==
nullptr) {
5509 if (
modifier->mesh_final->uv_map_names().is_empty()) {
5525 const MFace *mfaces =
static_cast<const MFace *
>(
5560 const MFace *mfaces =
static_cast<const MFace *
>(
5563 const MCol *mc =
static_cast<const MCol *
>(
5568 r_mcol[0] =
float(mcol.
b) / 255.0f;
5569 r_mcol[1] =
float(mcol.
g) / 255.0f;
5570 r_mcol[2] =
float(mcol.
r) / 255.0f;
5604 for (
int a = 0; a < psys.
totpart; a++, pa++) {
5638 ListBaseT<ParticleSystem> *particles)
5669 for (a = 1, pa++; a < psys.
totpart; a++, pa++) {
5670 pa->
boid = (pa - 1)->boid + 1;
5688 psys.
edit =
nullptr;
5720 psys.
tree =
nullptr;
5731 ListBaseT<ParticleSystem> *particles)
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
CustomData interface, see also DNA_customdata_types.h.
display list (or rather multi purpose list) stuff.
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define LOOP_SHOWN_PARTICLES
#define PTCACHE_CLEAR_ALL
A KD-tree for nearest neighbor search.
#define STRNCPY_UTF8(dst, src)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_PARTICLESETTINGS
Object groups, one object can be in many groups at once.
Read Blender memory allocation and freeing.
#define POINTER_AS_INT(i)
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define CD_MASK_ORIGINDEX
#define CD_MASK_MDEFORMVERT
#define CD_MASK_ORIGSPACE_MLOOP
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
constexpr const T * data() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
void transpose_m3_m4(float R[3][3], const float M[4][4])
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit)
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void mul_m3_v3(const float M[3][3], float r[3])
static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCacheKey *result)
void kdtree_balance(KDTree< CoordT > *tree)
void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
struct PartDeflect * BKE_partdeflect_new(ePFieldType type)
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
static int tessfaceidx_on_emitter(ParticleSystem *particlesystem, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, float(**r_fuv)[4])
struct ModifierData * object_add_particle_system(struct Main *bmain, const struct Scene *scene, struct Object *ob, const char *name)
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], float t)
static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind)
static void psys_thread_create_path(ParticleTask *task, ChildParticle *cpa, ParticleCacheKey *child_keys, int i)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
float do_clump(ParticleKey *state, const float par_co[3], float time, const float orco_offset[3], float clumpfac, float clumppow, float pa_clump, bool use_clump_noise, float clump_noise_size, const CurveMapping *clumpcurve)
void BKE_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, int mode)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx, float mat[4][4], ParticleKey *state, float t)
MINLINE void copy_v3_v3(float r[3], const float a[3])
Vector< ParticleTask > psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int endpart)
struct ParticleSystem * psys_get_current(struct Object *ob)
void psys_sim_data_init(struct ParticleSimulationData *sim)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
@ PFIELD_GUIDE_PATH_WEIGHT
void BKE_particle_mcol_on_emitter(ParticleSystem *particlesystem, ReportList *reports, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int vcol_no, float r_mcol[3])
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
static void particle_settings_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
static ModifierData * object_add_or_copy_particle_system(Main *bmain, const Scene *scene, Object *ob, const char *name, const ParticleSystem *psys_orig)
static void particle_settings_blend_read_data(BlendDataReader *reader, ID *id)
bool BKE_where_on_path(const struct Object *ob, float ctime, float r_vec[4], float r_dir[3], float r_quat[4], float *r_radius, float *r_weight)
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
Material * BKE_object_material_get(Object *ob, short act)
@ IDWALK_DO_DEPRECATED_POINTERS
struct RNG * BLI_rng_new_srandom(unsigned int seed)
void BLI_bvhtree_free(BVHTree *tree)
float * psys_cache_vgroup(struct Mesh *mesh, struct ParticleSystem *psys, int vgroup)
int BKE_ptcache_mem_index_find(struct PTCacheMem *pm, unsigned int index)
void cloth_free_modifier(ClothModifierData *clmd)
static float interpolate_particle_value(float v1, float v2, float v3, float v4, const float w[4], int four)
float BKE_scene_frame_to_ctime(const Scene *scene, int frame)
void void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, bool use_render_params)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
static float psys_interpolate_value_from_verts(Mesh *mesh, short from, int index, const float fw[4], const float *values)
@ eModifierType_ParticleSystem
@ eModifierType_DynamicPaint
MINLINE float safe_acosf(float a)
void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data, float co[3], float weight)
void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point)
struct PartDeflect * BKE_partdeflect_copy(const struct PartDeflect *pd_src)
static void get_pointcache_keys_for_time(Object *, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap)
void psys_find_parents(struct ParticleSimulationData *sim, bool use_render_params)
void psys_thread_context_init(struct ParticleThreadContext *ctx, struct ParticleSimulationData *sim)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
struct ModifierData * object_copy_particle_system(struct Main *bmain, const struct Scene *scene, struct Object *ob, const struct ParticleSystem *psys_orig)
void BKE_effectors_apply(ListBaseT< EffectorCache > *effectors, ListBaseT< ColliderCache > *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *wind_force, float *impulse)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void BKE_particle_partdeflect_blend_read_data(struct BlendDataReader *reader, struct PartDeflect *pd)
MINLINE int max_ii(int a, int b)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
void do_kink(ParticleKey *state, const float par_co[3], const float par_vel[3], const float par_rot[4], float time, float freq, float shape, float amplitude, float flat, short type, short axis, const float obmat[4][4], int smooth_start)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
struct ParticleSystem * psys_orig_get(struct ParticleSystem *psys)
@ PART_FLUID_SPRAYFOAMBUBBLE
void psys_interpolate_face(struct Mesh *mesh, const float(*vert_positions)[3], const float(*vert_normals)[3], const struct MFace *mface, struct MTFace *tface, const float(*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void psys_get_dupli_path_transform(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[4][4], float *scale)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void psys_apply_child_modifiers(struct ParticleThreadContext *ctx, ListBaseT< ModifierData > *modifiers, struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], float hairmat[4][4], struct ParticleCacheKey *keys, struct ParticleCacheKey *parent_keys, const float parent_orco[3])
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
void BKE_curvemapping_free(CurveMapping *cumap)
static void psys_w_to_origspace(const float w[4], float uv[2])
LibraryForeachIDFlag BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
void psys_free_particles(struct ParticleSystem *psys)
struct ParticleSettings * BKE_particlesettings_add(struct Main *bmain, const char *name)
float psys_get_timestep(struct ParticleSimulationData *sim)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
struct RNG * BLI_rng_new(unsigned int seed)
void BKE_modifiers_persistent_uid_init(const Object &object, ModifierData &md)
void BKE_particlesettings_twist_curve_init(struct ParticleSettings *part)
static void particle_settings_init(ID *id)
MINLINE void mul_v3_fl(float r[3], float f)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
void BKE_particle_system_blend_write(struct BlendWriter *writer, ListBaseT< ParticleSystem > *particles)
void BLI_task_pool_work_and_wait(TaskPool *pool)
float effector_falloff(struct EffectorCache *eff, struct EffectorData *efd, struct EffectedPoint *point, struct EffectorWeights *weights)
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
void BKE_ptcache_blend_read_data(struct BlendDataReader *reader, ListBaseT< PointCache > *ptcaches, struct PointCache **ocache, int force_disk)
void mul_qt_v3(const float q[4], float r[3])
void BKE_modifier_unique_name(ListBaseT< ModifierData > *modifiers, ModifierData *md)
void psys_get_particle_on_path(struct ParticleSimulationData *sim, int pa_num, struct ParticleKey *state, bool vel)
void BKE_particle_co_hair(const ParticleSystem *particlesystem, const Object *object, int particle_no, int step, float n_co[3])
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
bool psys_in_edit_mode(struct Depsgraph *depsgraph, const struct ParticleSystem *psys)
float PSYS_FRAND_BASE[PSYS_FRAND_COUNT]
void mul_m4_v3(const float M[4][4], float r[3])
static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx, ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void(*) BKE_particle_batch_cache_dirty_tag_cb(struct ParticleSystem *psys, int mode)
void BKE_curvemapping_init(CurveMapping *cumap)
int CustomData_get_render_layer(const CustomData *data, eCustomDataType type)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void(*) BKE_particle_batch_cache_free_cb(struct ParticleSystem *psys)
static void fluid_free_settings(SPHFluidSettings *fluid)
void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
static void psys_cache_edit_paths_iter(void *__restrict iter_data_v, const int iter, const TaskParallelTLS *__restrict)
static size_t boid_rule_struct_size(const eBoidRuleType type)
unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT]
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
static void psys_particle_on_shape(int, int, float *, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
struct BoidSettings * boid_copy_settings(const struct BoidSettings *boids)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
static void particle_settings_blend_read_after_liblink(BlendLibReader *, ID *id)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void copy_qt_qt(float q[4], const float a[4])
Main * DEG_get_bmain(const Depsgraph *graph)
void DEG_id_tag_update(ID *id, unsigned int flags)
void precalc_guides(struct ParticleSimulationData *sim, ListBaseT< EffectorCache > *effectors)
static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSimulationData *sim, Scene *scene, float cfra, const bool editupdate, const bool use_render_params)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void free_hair(struct Object *ob, struct ParticleSystem *psys, int dynamics)
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void psys_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
void BKE_modifiers_add_at_end_if_possible(Object *ob, ModifierData *new_md)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
static void edit_to_particle(ParticleKey *key, PTCacheEditKey *ekey)
int BKE_mesh_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
ModifierData * BKE_modifier_new(int type)
void BKE_particle_system_blend_read_after_liblink(struct BlendLibReader *reader, struct Object *ob, struct ID *id, ListBaseT< ParticleSystem > *particles)
void psys_free(struct Object *ob, struct ParticleSystem *psys)
void psys_particle_on_dm(struct Mesh *mesh_final, int from, int index, int index_dmcache, const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
void mat3_to_quat_legacy(float q[4], const float wmat[3][3])
void free_keyed_keys(struct ParticleSystem *psys)
void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4])
void BKE_modifier_free(ModifierData *md)
void psys_get_dupli_texture(struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float uv[2], float orco[3])
void BKE_mesh_texspace_ensure(Mesh *mesh)
void BLO_read_struct_list_with_type_size(BlendDataReader *reader, size_t base_size, ListBase *list, FunctionRef< size_t(const void *data)> type_size_fn)
float psys_get_dietime_from_cache(struct PointCache *cache, int index)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static int get_pointcache_times_for_particle(PointCache *cache, int index, float *r_start, float *r_dietime)
static void triatomat(float *v1, float *v2, float *v3, const float(*uv)[2], float mat[4][4])
@ PART_CHILD_USE_ROUGH_CURVE
@ PART_CHILD_USE_TWIST_CURVE
@ PART_CHILD_USE_CLUMP_NOISE
@ PART_CHILD_USE_CLUMP_CURVE
int kdtree_find_nearest(const KDTree< CoordT > *tree, const CoordT &co, KDTreeNearest< CoordT > *r_nearest)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void unit_m4(float m[4][4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void psys_mat_hair_to_object(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
static int get_particle_uv(Mesh *mesh, ParticleData *pa, int index, const float fuv[4], const char *name, float *texco, bool from_vert)
static void mvert_to_particle(ParticleKey *key, float3 *position, HairKey *hkey)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
void psys_find_group_weights(struct ParticleSettings *part)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
void psys_get_texture(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra)
static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBaseT< LinkData > *bufs)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
ATTR_WARN_UNUSED_RESULT const size_t num
void BKE_modifier_remove_from_list(Object *ob, ModifierData *md)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void interp_weights_poly_v3(float w[], float v[][3], int n, const float co[3])
@ SNDPARTICLE_COMBINED_EXPORT_OFF
void psys_interpolate_mcol(const struct MCol *mcol, int quad, const float w[4], struct MCol *mc)
void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float r_uv[2])
static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData *pa, float t, ParticleInterpolationData *pind, ParticleKey *result)
void psys_free_children(struct ParticleSystem *psys)
MINLINE void zero_v3(float r[3])
void BKE_id_free(Main *bmain, void *idv)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
static void exec_child_path_cache(TaskPool *__restrict, void *taskdata)
ListBaseT< Base > BKE_collection_object_cache_get(Collection *collection)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
void BKE_curvemapping_changed_all(CurveMapping *cumap)
float BKE_displist_calc_taper(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *taperobj, int cur, int tot)
static void particle_settings_foreach_id(ID *id, LibraryForeachIDData *data)
void BKE_mesh_orco_verts_transform(Mesh *mesh, MutableSpan< float3 > orco, bool invert)
void BLI_task_pool_free(TaskPool *pool)
int count_particles_mod(struct ParticleSystem *psys, int totgr, int cur)
void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time)
int count_particles(struct ParticleSystem *psys)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
short psys_get_current_num(struct Object *ob)
void BKE_partdeflect_free(struct PartDeflect *pd)
static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4][4], int orco)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])
void BKE_lattice_deform_data_destroy(LatticeDeformData *lattice_deform_data)
const void * CustomData_get_layer_n(const CustomData *data, eCustomDataType type, int n)
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
void int BLI_rng_get_int(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float normalize_v3(float n[3])
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
MINLINE void add_v3_v3(float r[3], const float a[3])
void kdtree_free(KDTree< CoordT > *tree)
void psys_set_current_num(struct Object *ob, int index)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void psys_disable_all(struct Object *ob)
void BKE_particlesettings_rough_curve_init(struct ParticleSettings *part)
void psys_free_pdd(struct ParticleSystem *psys)
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
void BKE_ptcache_free_list(ListBaseT< PointCache > *ptcaches)
void psys_vec_rot_to_face(struct Mesh *mesh, struct ParticleData *pa, float vec[3])
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void boid_free_settings(struct BoidSettings *boids)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void transpose_m4(float R[4][4])
int psys_particle_dm_face_lookup(struct Mesh *mesh_final, struct Mesh *mesh_original, int findex_orig, const float fw[4], struct LinkNode **poly_nodes)
static int psys_map_index_on_dm(Mesh *mesh, int from, int index, int index_dmcache, const float fw[4], float, int *mapindex, float mapfw[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void BKE_particlesettings_clump_curve_init(struct ParticleSettings *part)
float psys_particle_value_from_verts(struct Mesh *mesh, short from, struct ParticleData *pa, float *values)
void psys_thread_context_free(struct ParticleThreadContext *ctx)
Scene * DEG_get_input_scene(const Depsgraph *graph)
void psys_get_from_key(struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
void BKE_particle_batch_cache_free(struct ParticleSystem *psys)
void BKE_mesh_tessface_ensure(Mesh *mesh)
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex)
static void hair_to_particle(ParticleKey *key, HairKey *hkey)
struct PointCache * BKE_ptcache_add(ListBaseT< PointCache > *ptcaches)
void psys_cache_edit_paths(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, bool use_render_params)
void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float fuv[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void psys_copy_particles(struct ParticleSystem *psys_dst, struct ParticleSystem *psys_src)
static ParticleCacheKey ** psys_alloc_path_cache_buffers(ListBaseT< LinkData > *bufs, int tot, int totkeys)
void psys_tasks_free(Vector< ParticleTask > &tasks)
void BKE_particle_system_blend_read_data(struct BlendDataReader *reader, ListBaseT< ParticleSystem > *particles)
void DEG_relations_tag_update(Main *bmain)
void BKE_ptcache_blend_write(struct BlendWriter *writer, ListBaseT< PointCache > *ptcaches)
static ParticleCacheKey * pcache_key_segment_endpoint_safe(ParticleCacheKey *key)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, bool editupdate, bool use_render_params)
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
void psys_enable_all(struct Object *ob)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void key_curve_position_weights(float t, float data[4], KeyInterpolationType type)
void * CustomData_get_for_write(CustomData *data, int index, eCustomDataType type, int totelem)
static void particle_settings_free_data(ID *id)
unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT]
bool do_guides(struct Depsgraph *depsgraph, struct ParticleSettings *part, ListBaseT< EffectorCache > *effectors, ParticleKey *state, int index, float time)
void BKE_particle_init_rng()
VecBase< float, 3 > float3
void BKE_defvert_weight_to_rgb(float r_rgb[3], float weight)
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
static void free_child_path_cache(ParticleSystem *psys)
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
bool psys_check_edited(struct ParticleSystem *psys)
void BKE_particle_uv_on_emitter(ParticleSystem *particlesystem, ReportList *reports, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int uv_no, float r_uv[2])
void BKE_object_modifier_set_active(Object *ob, ModifierData *md)
static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4], float neww[4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void psys_mat_hair_to_orco(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
int psys_uses_gravity(struct ParticleSimulationData *sim)
void psys_check_group_weights(struct ParticleSettings *part)
LatticeDeformData * BKE_lattice_deform_data_create(const Object *oblatt, const Object *ob) ATTR_WARN_UNUSED_RESULT
@ SPH_VISCOELASTIC_SPRINGS
struct EffectorWeights * BKE_effector_add_weights(struct Collection *collection)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
float DEG_get_ctime(const Depsgraph *graph)
static PTCacheEdit * psys_orig_edit_get(ParticleSystem *psys)
void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity)
MINLINE void zero_v2(float r[2])
static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *, float effector, float, float, float *length, float *vec)
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
void * BKE_id_new(Main *bmain, short type, const char *name)
static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, ParticleKey *child, float flat, float radius)
@ eBoidRuleType_AverageSpeed
@ eBoidRuleType_FollowLeader
@ eBoidRuleType_AvoidCollision
void psys_sim_data_free(struct ParticleSimulationData *sim)
static void get_cpa_texture(Mesh *mesh, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra)
void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time)
void BKE_effectors_free(ListBaseT< EffectorCache > *lb)
static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCacheKey *key1, ParticleCacheKey *key2, float *prev_tangent, int i)
static void write_boid_state(BlendWriter *writer, BoidState *state)
void quat_to_mat4(float m[4][4], const float q[4])
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ FLUID_DOMAIN_PARTICLE_FLIP
@ FLUID_DOMAIN_PARTICLE_TRACER
@ FLUID_DOMAIN_PARTICLE_FOAM
@ FLUID_DOMAIN_PARTICLE_SPRAY
@ FLUID_DOMAIN_PARTICLE_BUBBLE
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname) ATTR_NONNULL(1
static void psys_task_init_path(ParticleTask *task, ParticleSimulationData *sim)
static void particle_settings_blend_write(BlendWriter *writer, ID *id, const void *id_address)
#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue)
#define CLAMP_WARP_PARTICLE_TEXTURE_POS(type, pvalue)
#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue)
#define PATH_CACHE_BUF_SIZE
#define SET_PARTICLE_TEXTURE(type, pvalue, texfac)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_cast(const void *data, 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)
ListBaseT< BoidState > states
ParticleSystemModifierData * psmd
struct Cloth * clothObject
struct ClothSolverResult * solver_result
struct ClothHairData * hairdata
struct ClothSimSettings * sim_parms
struct PointCache * point_cache
struct ListBaseT< PointCache > ptcaches
struct ClothCollSettings * coll_parms
struct EffectorWeights * effector_weights
struct ParticleSystem * psys
struct DynamicPaintBrushSettings * brush
struct Collection * group
eFluidDomain_ParticleTypes particle_type
eFluidDomain_SndParticleCombinedExport sndparticle_combined_export
struct ParticleSystem * psys
struct FluidFlowSettings * flow
struct FluidDomainSettings * domain
eMTex_BlendType blendtype
bke::MeshRuntime * runtime
struct ModifierData * next
ListBaseT< ModifierData > modifiers
ListBaseT< struct ParticleSystem > particlesystem
eObject_TransFlag transflag
struct PTCacheEditKey * keys
ListBaseT< LinkData > pathcachebufs
PTCacheEditPoint * points
struct ParticleSystem * psys
struct ParticleSystemModifierData * psmd_eval
struct ParticleCacheKey ** pathcache
ParticleCacheKey * parent_keys
ParticleSimulationData * sim
ParticleThreadContext * thread_ctx
struct ParticleDupliWeight * next
eParticleDupliWeight_Flag flag
PTCacheEditPoint * epoint
float3 * vert_positions[2]
eParticleChildFlag child_flag
struct Object * instance_object
ListBaseT< ParticleDupliWeight > instance_weights
struct Collection * collision_group
DNA_DEPRECATED struct Collection * force_group
struct BoidSettings * boids
struct SPHFluidSettings * fluid
eParticleDistribution distr
eParticleChildType childtype
eParticleRotationMode rotmode
eParticleDrawCol draw_col
eParticlePhysicsType phystype
struct CurveMapping * twistcurve
struct CurveMapping * clumpcurve
struct Collection * instance_collection
struct CurveMapping * roughcurve
struct EffectorWeights * effector_weights
ListBaseT< ColliderCache > * colliders
struct Depsgraph * depsgraph
struct ParticleSystem * psys
struct ParticleSystemModifierData * psmd
struct ParticleSystem * psys
ListBaseT< LinkData > pathcachebufs
struct ParticleDrawData * pdd
ListBaseT< LinkData > childcachebufs
draw::ParticleBatchCache * batch_cache
struct Mesh * hair_in_mesh
struct ClothModifierData * clmd
struct ParticleSystem * next
struct ParticleSystem * orig_psys
struct LatticeDeformData * lattice_deform_data
struct Mesh * hair_out_mesh
struct PTCacheEdit * edit
ListBaseT< ParticleTarget > targets
void(*) free_edit(struct PTCacheEdit *edit)
struct ListBaseT< struct EffectorCache > * effectors
ListBaseT< PointCache > ptcaches
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
eParticleSystem_Flag flag
struct PointCache * pointcache
ParticleSpring * fluid_springs
struct ParticleTarget * prev
struct ParticleTarget * next
ParticleThreadContext * ctx
struct CurveMapping * clumpcurve
struct CurveMapping * roughcurve
struct CurveMapping * twistcurve
struct ParticleSimulationData sim
ListBaseT< PTCacheMem > mem_cache
struct PTCacheEdit * edit
struct PhysicsSettings physics_settings
struct ToolSettings * toolsettings