Blender V5.3
MOD_explode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#define DNA_DEPRECATED_ALLOW /* For #ME_FACE_SEL. */
10
11#include "BLI_utildefines.hh"
12
13#include "BLI_array.hh"
14#include "BLI_kdtree.hh"
15#include "BLI_map.hh"
16#include "BLI_math_matrix_c.hh"
18#include "BLI_math_vector_c.hh"
19#include "BLI_rand_c.hh"
20
21#include "BLT_translation.hh"
22
23#include "DNA_mesh_types.h"
24#include "DNA_meshdata_types.h"
25#include "DNA_object_types.h"
26#include "DNA_screen_types.h"
27
29#include "BKE_customdata.hh"
30#include "BKE_deform.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_mesh.hh"
34#include "BKE_modifier.hh"
35#include "BKE_particle.h"
36#include "BKE_scene.hh"
37
39#include "UI_resources.hh"
40
41#include "RNA_access.hh"
42#include "RNA_prototypes.hh"
43
45
46#include "MEM_guardedalloc.h"
47
48#include "MOD_ui_common.hh"
49
50namespace blender {
51
53{
54 return static_cast<Array<int, 0> *>(emd->facepa);
55}
56
57static void init_data(ModifierData *md)
58{
59 ExplodeModifierData *emd = reinterpret_cast<ExplodeModifierData *>(md);
61}
62static void free_data(ModifierData *md)
63{
64 ExplodeModifierData *emd = reinterpret_cast<ExplodeModifierData *>(md);
65
66 if (emd->facepa) {
67 MEM_delete(facepa_array(emd));
68 emd->facepa = nullptr;
69 }
70}
71static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
72{
73#if 0
74 const ExplodeModifierData *emd = (const ExplodeModifierData *)md;
75#endif
76 ExplodeModifierData *temd = reinterpret_cast<ExplodeModifierData *>(target);
77
78 BKE_modifier_copydata_generic(md, target, flag);
79
80 temd->facepa = nullptr;
81}
82static bool depends_on_time(Scene * /*scene*/, ModifierData * /*md*/)
83{
84 return true;
85}
86static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
87{
88 ExplodeModifierData *emd = reinterpret_cast<ExplodeModifierData *>(md);
89
90 if (emd->vgroup) {
91 r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
92 }
93}
94
96{
97 ParticleSystem *psys = psmd->psys;
98 MFace *fa = nullptr, *mface = nullptr;
99 ParticleData *pa;
100 KDTree<float3> *tree;
101 RNG *rng;
102 float center[3], co[3];
103 int *facepa = nullptr, *vertpa = nullptr, totvert = 0, totface = 0, totpart = 0;
104 int i, p, v1, v2, v3, v4 = 0;
105 const bool invert_vgroup = (emd->flag & eExplodeFlag_INVERT_VGROUP) != 0;
106
107 MutableSpan<float3> positions = mesh->vert_positions_for_write();
108 mface = static_cast<MFace *>(
109 CustomData_get_layer_for_write(&mesh->fdata_legacy, CD_MFACE, mesh->totface_legacy));
110 totvert = mesh->verts_num;
111 totface = mesh->totface_legacy;
112 totpart = psmd->psys->totpart;
113
114 rng = BLI_rng_new_srandom(psys->seed);
115
116 if (emd->facepa) {
117 MEM_delete(facepa_array(emd));
118 }
119 auto *facepa_array = MEM_new<Array<int, 0>>(__func__, totface, 0);
120 emd->facepa = facepa_array;
121 facepa = facepa_array->data();
122
123 vertpa = MEM_new_array_zeroed<int>(totvert, __func__);
124
125 /* initialize all faces & verts to no particle */
126 for (i = 0; i < totface; i++) {
127 facepa[i] = totpart;
128 }
129 for (i = 0; i < totvert; i++) {
130 vertpa[i] = totpart;
131 }
132
133 /* set protected verts */
134 if (emd->vgroup) {
135 const MDeformVert *dvert = mesh->deform_verts().data();
136 if (dvert) {
137 const int defgrp_index = emd->vgroup - 1;
138 for (i = 0; i < totvert; i++, dvert++) {
139 float val = BLI_rng_get_float(rng);
140 val = (1.0f - emd->protect) * val + emd->protect * 0.5f;
141 const float weight = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dvert, defgrp_index) :
142 BKE_defvert_find_weight(dvert, defgrp_index);
143 if (val < weight) {
144 vertpa[i] = -1;
145 }
146 }
147 }
148 }
149
150 /* make tree of emitter locations */
151 tree = kdtree_new<float3>(totpart);
152 for (p = 0, pa = psys->particles; p < totpart; p++, pa++) {
154 psys->part->from,
155 pa->num,
156 pa->num_dmcache,
157 pa->fuv,
158 pa->foffset,
159 co,
160 nullptr,
161 nullptr,
162 nullptr,
163 nullptr);
164 kdtree_insert<float3>(tree, p, co);
165 }
167
168 /* set face-particle-indexes to nearest particle to face center */
169 for (i = 0, fa = mface; i < totface; i++, fa++) {
170 add_v3_v3v3(center, positions[fa->v1], positions[fa->v2]);
171 add_v3_v3(center, positions[fa->v3]);
172 if (fa->v4) {
173 add_v3_v3(center, positions[fa->v4]);
174 mul_v3_fl(center, 0.25);
175 }
176 else {
177 mul_v3_fl(center, 1.0f / 3.0f);
178 }
179
180 p = kdtree_find_nearest<float3>(tree, center, nullptr);
181
182 v1 = vertpa[fa->v1];
183 v2 = vertpa[fa->v2];
184 v3 = vertpa[fa->v3];
185 if (fa->v4) {
186 v4 = vertpa[fa->v4];
187 }
188
189 if (v1 >= 0 && v2 >= 0 && v3 >= 0 && (fa->v4 == 0 || v4 >= 0)) {
190 facepa[i] = p;
191 }
192
193 if (v1 >= 0) {
194 vertpa[fa->v1] = p;
195 }
196 if (v2 >= 0) {
197 vertpa[fa->v2] = p;
198 }
199 if (v3 >= 0) {
200 vertpa[fa->v3] = p;
201 }
202 if (fa->v4 && v4 >= 0) {
203 vertpa[fa->v4] = p;
204 }
205 }
206
207 if (vertpa) {
208 MEM_delete(vertpa);
209 }
211
212 BLI_rng_free(rng);
213}
214
215static int edgecut_get(const Map<OrderedEdge, int> &edgehash, uint v1, uint v2)
216{
217 return edgehash.lookup({int(v1), int(v2)});
218}
219
220static const short add_faces[24] = {
221 0, 0, 0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 2, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2,
222};
223
224static MFace *get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
225{
226 MFace *mfaces = static_cast<MFace *>(
227 CustomData_get_layer_for_write(&split->fdata_legacy, CD_MFACE, split->totface_legacy));
228 MFace *df = &mfaces[cur];
229 CustomData_copy_data(&mesh->fdata_legacy, &split->fdata_legacy, i, cur, 1);
230 *df = *mf;
231 return df;
232}
233
234#define SET_VERTS(a, b, c, d) \
235 { \
236 v[0] = mf->v##a; \
237 uv[0] = a - 1; \
238 v[1] = mf->v##b; \
239 uv[1] = b - 1; \
240 v[2] = mf->v##c; \
241 uv[2] = c - 1; \
242 v[3] = mf->v##d; \
243 uv[3] = d - 1; \
244 } \
245 (void)0
246
247#define GET_ES(v1, v2) edgecut_get(eh, v1, v2)
248#define INT_UV(uvf, c0, c1) mid_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1])
249
251 Mesh *split,
252 MFace *mf,
253 int *facepa,
254 const int *vertpa,
255 int i,
256 const Map<OrderedEdge, int> &eh,
257 int cur,
258 int v1,
259 int v2,
260 int v3,
261 int v4)
262{
263 MFace *df1 = get_dface(mesh, split, cur, i, mf);
264 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
265 MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
266
267 facepa[cur] = vertpa[v1];
268 df1->v1 = v1;
269 df1->v2 = GET_ES(v1, v2);
270 df1->v3 = GET_ES(v2, v3);
271 df1->v4 = v3;
272 df1->flag |= ME_FACE_SEL;
273
274 facepa[cur + 1] = vertpa[v2];
275 df2->v1 = GET_ES(v1, v2);
276 df2->v2 = v2;
277 df2->v3 = GET_ES(v2, v3);
278 df2->v4 = 0;
279 df2->flag &= ~ME_FACE_SEL;
280
281 facepa[cur + 2] = vertpa[v1];
282 df3->v1 = v1;
283 df3->v2 = v3;
284 df3->v3 = v4;
285 df3->v4 = 0;
286 df3->flag &= ~ME_FACE_SEL;
287}
288
290 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
291{
292 MTFace *mf, *df1, *df2, *df3;
293 int l;
294
295 for (l = 0; l < layers_num; l++) {
296 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
297 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
298 df1 = mf + cur;
299 df2 = df1 + 1;
300 df3 = df1 + 2;
301 mf = static_cast<MTFace *>(
302 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
303 mf += i;
304
305 copy_v2_v2(df1->uv[0], mf->uv[c0]);
306 INT_UV(df1->uv[1], c0, c1);
307 INT_UV(df1->uv[2], c1, c2);
308 copy_v2_v2(df1->uv[3], mf->uv[c2]);
309
310 INT_UV(df2->uv[0], c0, c1);
311 copy_v2_v2(df2->uv[1], mf->uv[c1]);
312 INT_UV(df2->uv[2], c1, c2);
313
314 copy_v2_v2(df3->uv[0], mf->uv[c0]);
315 copy_v2_v2(df3->uv[1], mf->uv[c2]);
316 copy_v2_v2(df3->uv[2], mf->uv[c3]);
317 }
318}
319
321 Mesh *split,
322 MFace *mf,
323 int *facepa,
324 const int *vertpa,
325 int i,
326 const Map<OrderedEdge, int> &eh,
327 int cur,
328 int v1,
329 int v2,
330 int v3,
331 int v4)
332{
333 MFace *df1 = get_dface(mesh, split, cur, i, mf);
334 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
335
336 facepa[cur] = vertpa[v1];
337 df1->v1 = v1;
338 df1->v2 = v2;
339 df1->v3 = GET_ES(v2, v3);
340 df1->v4 = GET_ES(v1, v4);
341 df1->flag |= ME_FACE_SEL;
342
343 facepa[cur + 1] = vertpa[v3];
344 df2->v1 = GET_ES(v1, v4);
345 df2->v2 = GET_ES(v2, v3);
346 df2->v3 = v3;
347 df2->v4 = v4;
348 df2->flag |= ME_FACE_SEL;
349}
350
351static void remap_uvs_5_10(
352 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
353{
354 MTFace *mf, *df1, *df2;
355 int l;
356
357 for (l = 0; l < layers_num; l++) {
358 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
359 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
360 df1 = mf + cur;
361 df2 = df1 + 1;
362 mf = static_cast<MTFace *>(
363 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
364 mf += i;
365
366 copy_v2_v2(df1->uv[0], mf->uv[c0]);
367 copy_v2_v2(df1->uv[1], mf->uv[c1]);
368 INT_UV(df1->uv[2], c1, c2);
369 INT_UV(df1->uv[3], c0, c3);
370
371 INT_UV(df2->uv[0], c0, c3);
372 INT_UV(df2->uv[1], c1, c2);
373 copy_v2_v2(df2->uv[2], mf->uv[c2]);
374 copy_v2_v2(df2->uv[3], mf->uv[c3]);
375 }
376}
377
379 Mesh *split,
380 MFace *mf,
381 int *facepa,
382 const int *vertpa,
383 int i,
384 const Map<OrderedEdge, int> &eh,
385 int cur,
386 int v1,
387 int v2,
388 int v3,
389 int v4)
390{
391 MFace *df1 = get_dface(mesh, split, cur, i, mf);
392 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
393 MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
394 MFace *df4 = get_dface(mesh, split, cur + 3, i, mf);
395
396 facepa[cur] = vertpa[v1];
397 df1->v1 = v1;
398 df1->v2 = GET_ES(v1, v2);
399 df1->v3 = GET_ES(v1, v3);
400 df1->v4 = GET_ES(v1, v4);
401 df1->flag |= ME_FACE_SEL;
402
403 facepa[cur + 1] = vertpa[v2];
404 df2->v1 = GET_ES(v1, v2);
405 df2->v2 = v2;
406 df2->v3 = GET_ES(v2, v3);
407 df2->v4 = GET_ES(v1, v3);
408 df2->flag |= ME_FACE_SEL;
409
410 facepa[cur + 2] = vertpa[v3];
411 df3->v1 = GET_ES(v1, v3);
412 df3->v2 = GET_ES(v2, v3);
413 df3->v3 = v3;
414 df3->v4 = GET_ES(v3, v4);
415 df3->flag |= ME_FACE_SEL;
416
417 facepa[cur + 3] = vertpa[v4];
418 df4->v1 = GET_ES(v1, v4);
419 df4->v2 = GET_ES(v1, v3);
420 df4->v3 = GET_ES(v3, v4);
421 df4->v4 = v4;
422 df4->flag |= ME_FACE_SEL;
423}
424
425static void remap_uvs_15(
426 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
427{
428 MTFace *mf, *df1, *df2, *df3, *df4;
429 int l;
430
431 for (l = 0; l < layers_num; l++) {
432 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
433 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
434 df1 = mf + cur;
435 df2 = df1 + 1;
436 df3 = df1 + 2;
437 df4 = df1 + 3;
438 mf = static_cast<MTFace *>(
439 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
440 mf += i;
441
442 copy_v2_v2(df1->uv[0], mf->uv[c0]);
443 INT_UV(df1->uv[1], c0, c1);
444 INT_UV(df1->uv[2], c0, c2);
445 INT_UV(df1->uv[3], c0, c3);
446
447 INT_UV(df2->uv[0], c0, c1);
448 copy_v2_v2(df2->uv[1], mf->uv[c1]);
449 INT_UV(df2->uv[2], c1, c2);
450 INT_UV(df2->uv[3], c0, c2);
451
452 INT_UV(df3->uv[0], c0, c2);
453 INT_UV(df3->uv[1], c1, c2);
454 copy_v2_v2(df3->uv[2], mf->uv[c2]);
455 INT_UV(df3->uv[3], c2, c3);
456
457 INT_UV(df4->uv[0], c0, c3);
458 INT_UV(df4->uv[1], c0, c2);
459 INT_UV(df4->uv[2], c2, c3);
460 copy_v2_v2(df4->uv[3], mf->uv[c3]);
461 }
462}
463
465 Mesh *split,
466 MFace *mf,
467 int *facepa,
468 const int *vertpa,
469 int i,
470 const Map<OrderedEdge, int> &eh,
471 int cur,
472 int v1,
473 int v2,
474 int v3,
475 int v4)
476{
477 MFace *df1 = get_dface(mesh, split, cur, i, mf);
478 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
479 MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
480
481 facepa[cur] = vertpa[v1];
482 df1->v1 = v1;
483 df1->v2 = GET_ES(v1, v2);
484 df1->v3 = GET_ES(v2, v3);
485 df1->v4 = GET_ES(v1, v4);
486 df1->flag |= ME_FACE_SEL;
487
488 facepa[cur + 1] = vertpa[v2];
489 df2->v1 = GET_ES(v1, v2);
490 df2->v2 = v2;
491 df2->v3 = GET_ES(v2, v3);
492 df2->v4 = 0;
493 df2->flag &= ~ME_FACE_SEL;
494
495 facepa[cur + 2] = vertpa[v4];
496 df3->v1 = GET_ES(v1, v4);
497 df3->v2 = GET_ES(v2, v3);
498 df3->v3 = v3;
499 df3->v4 = v4;
500 df3->flag |= ME_FACE_SEL;
501}
502
504 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
505{
506 MTFace *mf, *df1, *df2, *df3;
507 int l;
508
509 for (l = 0; l < layers_num; l++) {
510 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
511 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
512 df1 = mf + cur;
513 df2 = df1 + 1;
514 df3 = df1 + 2;
515 mf = static_cast<MTFace *>(
516 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
517 mf += i;
518
519 copy_v2_v2(df1->uv[0], mf->uv[c0]);
520 INT_UV(df1->uv[1], c0, c1);
521 INT_UV(df1->uv[2], c1, c2);
522 INT_UV(df1->uv[3], c0, c3);
523
524 INT_UV(df2->uv[0], c0, c1);
525 copy_v2_v2(df2->uv[1], mf->uv[c1]);
526 INT_UV(df2->uv[2], c1, c2);
527
528 INT_UV(df3->uv[0], c0, c3);
529 INT_UV(df3->uv[1], c1, c2);
530 copy_v2_v2(df3->uv[2], mf->uv[c2]);
531 copy_v2_v2(df3->uv[3], mf->uv[c3]);
532 }
533}
534
536 Mesh *split,
537 MFace *mf,
538 int *facepa,
539 const int *vertpa,
540 int i,
541 const Map<OrderedEdge, int> &eh,
542 int cur,
543 int v1,
544 int v2,
545 int v3)
546{
547 MFace *df1 = get_dface(mesh, split, cur, i, mf);
548 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
549
550 facepa[cur] = vertpa[v1];
551 df1->v1 = v1;
552 df1->v2 = GET_ES(v1, v2);
553 df1->v3 = GET_ES(v1, v3);
554 df1->v4 = 0;
555 df1->flag &= ~ME_FACE_SEL;
556
557 facepa[cur + 1] = vertpa[v2];
558 df2->v1 = GET_ES(v1, v2);
559 df2->v2 = v2;
560 df2->v3 = v3;
561 df2->v4 = GET_ES(v1, v3);
562 df2->flag |= ME_FACE_SEL;
563}
564
566 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2)
567{
568 MTFace *mf, *df1, *df2;
569 int l;
570
571 for (l = 0; l < layers_num; l++) {
572 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
573 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
574 df1 = mf + cur;
575 df2 = df1 + 1;
576 mf = static_cast<MTFace *>(
577 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
578 mf += i;
579
580 copy_v2_v2(df1->uv[0], mf->uv[c0]);
581 INT_UV(df1->uv[1], c0, c1);
582 INT_UV(df1->uv[2], c0, c2);
583
584 INT_UV(df2->uv[0], c0, c1);
585 copy_v2_v2(df2->uv[1], mf->uv[c1]);
586 copy_v2_v2(df2->uv[2], mf->uv[c2]);
587 INT_UV(df2->uv[3], c0, c2);
588 }
589}
590
592 Mesh *split,
593 MFace *mf,
594 int *facepa,
595 const int *vertpa,
596 int i,
597 const Map<OrderedEdge, int> &eh,
598 int cur,
599 int v1,
600 int v2,
601 int v3)
602{
603 MFace *df1 = get_dface(mesh, split, cur, i, mf);
604 MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
605 MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
606
607 facepa[cur] = vertpa[v1];
608 df1->v1 = v1;
609 df1->v2 = GET_ES(v1, v2);
610 df1->v3 = GET_ES(v2, v3);
611 df1->v4 = GET_ES(v1, v3);
612 df1->flag |= ME_FACE_SEL;
613
614 facepa[cur + 1] = vertpa[v2];
615 df2->v1 = GET_ES(v1, v2);
616 df2->v2 = v2;
617 df2->v3 = GET_ES(v2, v3);
618 df2->v4 = 0;
619 df2->flag &= ~ME_FACE_SEL;
620
621 facepa[cur + 2] = vertpa[v3];
622 df3->v1 = GET_ES(v1, v3);
623 df3->v2 = GET_ES(v2, v3);
624 df3->v3 = v3;
625 df3->v4 = 0;
626 df3->flag &= ~ME_FACE_SEL;
627}
628
629static void remap_uvs_23(
630 Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2)
631{
632 MTFace *mf, *df1, *df2;
633 int l;
634
635 for (l = 0; l < layers_num; l++) {
636 mf = static_cast<MTFace *>(CustomData_get_layer_n_for_write(
637 &split->fdata_legacy, CD_MTFACE, l, split->totface_legacy));
638 df1 = mf + cur;
639 df2 = df1 + 1;
640 mf = static_cast<MTFace *>(
641 CustomData_get_layer_n_for_write(&mesh->fdata_legacy, CD_MTFACE, l, mesh->totface_legacy));
642 mf += i;
643
644 copy_v2_v2(df1->uv[0], mf->uv[c0]);
645 INT_UV(df1->uv[1], c0, c1);
646 INT_UV(df1->uv[2], c1, c2);
647 INT_UV(df1->uv[3], c0, c2);
648
649 INT_UV(df2->uv[0], c0, c1);
650 copy_v2_v2(df2->uv[1], mf->uv[c1]);
651 INT_UV(df2->uv[2], c1, c2);
652
653 INT_UV(df2->uv[0], c0, c2);
654 INT_UV(df2->uv[1], c1, c2);
655 copy_v2_v2(df2->uv[2], mf->uv[c2]);
656 }
657}
658
660{
661 Mesh *split_m;
662 MFace *mf = nullptr, *df1 = nullptr;
663 MFace *mface = static_cast<MFace *>(
664 CustomData_get_layer_for_write(&mesh->fdata_legacy, CD_MFACE, mesh->totface_legacy));
665 float *dupve;
666 int totvert = mesh->verts_num;
667 int totface = mesh->totface_legacy;
668
669 int *facesplit = MEM_new_array_zeroed<int>(totface, __func__);
670 int *vertpa = MEM_new_array_zeroed<int>(totvert, __func__);
671 int *facepa = facepa_array(emd)->data();
672 int *fs, totfsplit = 0, curdupface = 0;
673 int i, v1, v2, v3, v4, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */
674 uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */
675 int layers_num;
676
677 int totesplit = totvert;
678 Map<OrderedEdge, int> edgehash;
679
680 /* recreate vertpa from facepa calculation */
681 for (i = 0, mf = mface; i < totface; i++, mf++) {
682 vertpa[mf->v1] = facepa[i];
683 vertpa[mf->v2] = facepa[i];
684 vertpa[mf->v3] = facepa[i];
685 if (mf->v4) {
686 vertpa[mf->v4] = facepa[i];
687 }
688 }
689
690 /* mark edges for splitting and how to split faces */
691 for (i = 0, mf = mface, fs = facesplit; i < totface; i++, mf++, fs++) {
692 v1 = vertpa[mf->v1];
693 v2 = vertpa[mf->v2];
694 v3 = vertpa[mf->v3];
695
696 if (v1 != v2) {
697 edgehash.lookup_or_add_cb({mf->v1, mf->v2}, [&]() { return totesplit++; });
698 (*fs) |= 1;
699 }
700
701 if (v2 != v3) {
702 edgehash.lookup_or_add_cb({mf->v2, mf->v3}, [&]() { return totesplit++; });
703 (*fs) |= 2;
704 }
705
706 if (mf->v4) {
707 v4 = vertpa[mf->v4];
708
709 if (v3 != v4) {
710 edgehash.lookup_or_add_cb({mf->v3, mf->v4}, [&]() { return totesplit++; });
711 (*fs) |= 4;
712 }
713
714 if (v1 != v4) {
715 edgehash.lookup_or_add_cb({mf->v1, mf->v4}, [&]() { return totesplit++; });
716 (*fs) |= 8;
717 }
718
719 /* mark center vertex as a fake edge split */
720 if (*fs == 15) {
721 edgehash.lookup_or_add_cb({mf->v1, mf->v3}, [&]() { return totesplit++; });
722 }
723 }
724 else {
725 (*fs) |= 16; /* mark face as tri */
726
727 if (v1 != v3) {
728 edgehash.lookup_or_add_cb({mf->v1, mf->v3}, [&]() { return totesplit++; });
729 (*fs) |= 4;
730 }
731 }
732 }
733
734 /* count splits & create indexes for new verts */
735
736 /* count new faces due to splitting */
737 for (i = 0, fs = facesplit; i < totface; i++, fs++) {
738 totfsplit += add_faces[*fs];
739 }
740
742 mesh, totesplit, 0, totface + totfsplit, 0, 0, CD_MASK_EVERYTHING);
743
744 layers_num = CustomData_number_of_layers(&split_m->fdata_legacy, CD_MTFACE);
745
746 MutableSpan<float3> split_m_positions = split_m->vert_positions_for_write();
747
748 /* copy new faces & verts (is it really this painful with custom data??) */
750 for (i = 0; i < totvert; i++) {
751 vert_interp.copy(i, i, 1);
752 }
753
754 /* override original facepa (original pointer is saved in caller function) */
755
756 /* TODO(@ideasman42): `(totfsplit * 2)` over allocation is used since the quads are
757 * later interpreted as triangles, for this to work right I think we probably
758 * have to stop using tessface. */
759
760 auto *facepa_array = MEM_new<Array<int, 0>>(
761 __func__, size_t(totface) + (size_t(totfsplit) * 2), 0);
762 facepa = facepa_array->data();
763 // memcpy(facepa, emd->facepa, totface*sizeof(int));
764 emd->facepa = facepa_array;
765
766 /* create new verts */
767 for (const auto [edge, esplit] : edgehash.items()) {
768 const int ed_v1 = edge.v_low;
769 const int ed_v2 = edge.v_high;
770
771 vert_interp.copy(ed_v2, esplit, 1);
772
773 dupve = split_m_positions[esplit];
774 copy_v3_v3(dupve, split_m_positions[ed_v2]);
775
776 mid_v3_v3v3(dupve, dupve, split_m_positions[ed_v1]);
777 }
778
779 /* create new faces */
780 curdupface = 0; //=totface;
781 // curdupin=totesplit;
782 for (i = 0, fs = facesplit; i < totface; i++, fs++) {
783 mf = &mface[i];
784
785 switch (*fs) {
786 case 3:
787 case 10:
788 case 11:
789 case 15:
790 SET_VERTS(1, 2, 3, 4);
791 break;
792 case 5:
793 case 6:
794 case 7:
795 SET_VERTS(2, 3, 4, 1);
796 break;
797 case 9:
798 case 13:
799 SET_VERTS(4, 1, 2, 3);
800 break;
801 case 12:
802 case 14:
803 SET_VERTS(3, 4, 1, 2);
804 break;
805 case 21:
806 case 23:
807 SET_VERTS(1, 2, 3, 4);
808 break;
809 case 19:
810 SET_VERTS(2, 3, 1, 4);
811 break;
812 case 22:
813 SET_VERTS(3, 1, 2, 4);
814 break;
815 }
816
817 switch (*fs) {
818 case 3:
819 case 6:
820 case 9:
821 case 12:
823 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
824 if (layers_num) {
825 remap_uvs_3_6_9_12(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
826 }
827 break;
828 case 5:
829 case 10:
831 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
832 if (layers_num) {
833 remap_uvs_5_10(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
834 }
835 break;
836 case 15:
838 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
839 if (layers_num) {
840 remap_uvs_15(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
841 }
842 break;
843 case 7:
844 case 11:
845 case 13:
846 case 14:
848 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
849 if (layers_num) {
851 mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
852 }
853 break;
854 case 19:
855 case 21:
856 case 22:
858 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
859 if (layers_num) {
860 remap_uvs_19_21_22(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2]);
861 }
862 break;
863 case 23:
865 mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
866 if (layers_num) {
867 remap_uvs_23(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2]);
868 }
869 break;
870 case 0:
871 case 16:
872 df1 = get_dface(mesh, split_m, curdupface, i, mf);
873 facepa[curdupface] = vertpa[mf->v1];
874
875 if (df1->v4) {
876 df1->flag |= ME_FACE_SEL;
877 }
878 else {
879 df1->flag &= ~ME_FACE_SEL;
880 }
881 break;
882 }
883
884 curdupface += add_faces[*fs] + 1;
885 }
886
887 MFace *split_mface = static_cast<MFace *>(
889 for (i = 0; i < curdupface; i++) {
890 mf = &split_mface[i];
892 mf, &split_m->fdata_legacy, i, ((mf->flag & ME_FACE_SEL) ? 4 : 3));
893 }
894
895 MEM_delete(facesplit);
896 MEM_delete(vertpa);
897
900
901 return split_m;
902}
905 const ModifierEvalContext *ctx,
906 Scene *scene,
907 Mesh *to_explode)
908{
909 Mesh *explode, *mesh = to_explode;
910 MFace *mf = nullptr, *mface;
911 // ParticleSettings *part=psmd->psys->part; /* UNUSED */
912 ParticleSimulationData sim = {nullptr};
913 ParticleData *pa = nullptr, *pars = psmd->psys->particles;
914 ParticleKey state, birth;
915 float *vertco = nullptr, imat[4][4];
916 float rot[4];
917 float ctime;
918 // float timestep;
919 const int *facepa = facepa_array(emd)->data();
920 int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0;
921 int i, u;
922 uint mindex = 0;
923
924 totface = mesh->totface_legacy;
925 totvert = mesh->verts_num;
926 mface = static_cast<MFace *>(
927 CustomData_get_layer_for_write(&mesh->fdata_legacy, CD_MFACE, mesh->totface_legacy));
928 totpart = psmd->psys->totpart;
929
930 sim.depsgraph = ctx->depsgraph;
931 sim.scene = scene;
932 sim.ob = ctx->object;
933 sim.psys = psmd->psys;
934 sim.psmd = psmd;
935
936 // timestep = psys_get_timestep(&sim);
937
938 ctime = BKE_scene_ctime_get(scene);
939
940 /* hash table for vertex <-> particle relations */
941 Map<OrderedEdge, int> vertpahash;
942
943 for (i = 0; i < totface; i++) {
944 if (facepa[i] != totpart) {
945 pa = pars + facepa[i];
946
947 if ((pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) ||
948 (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) ||
949 (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0))
950 {
951 delface++;
952 continue;
953 }
954 }
955 else {
956 pa = nullptr;
957 }
958
959 /* do mindex + totvert to ensure the vertex index to be the first. */
960 if (pa == nullptr || ctime < pa->time) {
961 mindex = totvert + totpart;
962 }
963 else {
964 mindex = totvert + facepa[i];
965 }
966
967 mf = &mface[i];
968
969 /* set face vertices to exist in particle group */
970 vertpahash.lookup_or_add_cb({mf->v1, mindex}, [&]() { return totdup++; });
971 vertpahash.lookup_or_add_cb({mf->v2, mindex}, [&]() { return totdup++; });
972 vertpahash.lookup_or_add_cb({mf->v3, mindex}, [&]() { return totdup++; });
973 if (mf->v4) {
974 vertpahash.lookup_or_add_cb({mf->v4, mindex}, [&]() { return totdup++; });
975 }
976 }
977
978 /* the final duplicated vertices */
980 mesh, totdup, 0, totface - delface, 0, 0, CD_MASK_EVERYTHING);
981
982 MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer_named_for_write(
983 &explode->fdata_legacy, CD_MTFACE, emd->uvname, explode->totface_legacy));
984
985 /* getting back to object space */
986 invert_m4_m4(imat, ctx->object->object_to_world().ptr());
987
988 psys_sim_data_init(&sim);
989
990 const Span<float3> positions = mesh->vert_positions();
991 MutableSpan<float3> explode_positions = explode->vert_positions_for_write();
992
994
995 for (const auto [edge, v] : vertpahash.items()) {
996 int ed_v1 = edge.v_low;
997 int ed_v2 = edge.v_high;
998 ed_v2 -= totvert;
999
1000 copy_v3_v3(explode_positions[v], positions[ed_v1]);
1001
1002 vert_interp.copy(ed_v1, v, 1);
1003
1004 copy_v3_v3(explode_positions[v], positions[ed_v1]);
1005
1006 if (ed_v2 != totpart) {
1007 /* get particle */
1008 pa = pars + ed_v2;
1009
1010 psys_get_birth_coords(&sim, pa, &birth, 0, 0);
1011
1012 state.time = ctime;
1013 psys_get_particle_state(&sim, ed_v2, &state, true);
1014
1015 vertco = explode_positions[v];
1016 mul_m4_v3(ctx->object->object_to_world().ptr(), vertco);
1017
1018 sub_v3_v3(vertco, birth.co);
1019
1020 /* apply rotation, size & location */
1021 sub_qt_qtqt(rot, state.rot, birth.rot);
1022 mul_qt_v3(rot, vertco);
1023
1024 if (emd->flag & eExplodeFlag_PaSize) {
1025 mul_v3_fl(vertco, pa->size);
1026 }
1027
1028 add_v3_v3(vertco, state.co);
1029
1030 mul_m4_v3(imat, vertco);
1031 }
1032 else {
1033 pa = nullptr;
1034 }
1035 }
1036
1037 /* Map new vertices to faces. */
1038 MFace *explode_mface = static_cast<MFace *>(
1040 for (i = 0, u = 0; i < totface; i++) {
1041 MFace source;
1042 int orig_v4;
1043
1044 if (facepa[i] != totpart) {
1045 pa = pars + facepa[i];
1046
1047 if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) {
1048 continue;
1049 }
1050 if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) {
1051 continue;
1052 }
1053 if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) {
1054 continue;
1055 }
1056 }
1057 else {
1058 pa = nullptr;
1059 }
1060
1061 source = mface[i];
1062 mf = &explode_mface[u];
1063
1064 orig_v4 = source.v4;
1065
1066 /* Same as above in the first loop over mesh's faces. */
1067 if (pa == nullptr || ctime < pa->time) {
1068 mindex = totvert + totpart;
1069 }
1070 else {
1071 mindex = totvert + facepa[i];
1072 }
1073
1074 source.v1 = edgecut_get(vertpahash, source.v1, mindex);
1075 source.v2 = edgecut_get(vertpahash, source.v2, mindex);
1076 source.v3 = edgecut_get(vertpahash, source.v3, mindex);
1077 if (source.v4) {
1078 source.v4 = edgecut_get(vertpahash, source.v4, mindex);
1079 }
1080
1081 CustomData_copy_data(&mesh->fdata_legacy, &explode->fdata_legacy, i, u, 1);
1082
1083 *mf = source;
1084
1085 /* override uv channel for particle age */
1086 if (mtface) {
1087 float age = (pa != nullptr) ? (ctime - pa->time) / pa->lifetime : 0.0f;
1088 /* Clamp to this range to avoid flipping to the other side of the coordinates. */
1089 CLAMP(age, 0.001f, 0.999f);
1090
1091 MTFace *mtf = mtface + u;
1092
1093 mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = age;
1094 mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = 0.5f;
1095 }
1096
1097 BKE_mesh_mface_index_validate(mf, &explode->fdata_legacy, u, (orig_v4 ? 4 : 3));
1098 u++;
1099 }
1100
1101 /* finalization */
1104
1105 psys_sim_data_free(&sim);
1106
1107 return explode;
1108}
1109
1111{
1112 ModifierData *md;
1113 ParticleSystemModifierData *psmd = nullptr;
1114
1115 for (md = ob->modifiers.first(); emd != md; md = md->next) {
1117 psmd = reinterpret_cast<ParticleSystemModifierData *>(md);
1118 }
1119 }
1120 return psmd;
1121}
1123{
1124 ExplodeModifierData *emd = reinterpret_cast<ExplodeModifierData *>(md);
1126
1127 if (psmd) {
1128 ParticleSystem *psys = psmd->psys;
1129
1130 if (psys == nullptr || psys->totpart == 0) {
1131 return mesh;
1132 }
1133 if (psys->part == nullptr || psys->particles == nullptr) {
1134 return mesh;
1135 }
1136 if (psmd->mesh_final == nullptr) {
1137 return mesh;
1138 }
1139
1140 BKE_mesh_tessface_ensure(mesh); /* BMESH - UNTIL MODIFIER IS UPDATED FOR POLYGONS */
1141
1142 /* 1. find faces to be exploded if needed */
1143 if (emd->facepa == nullptr || psmd->flag & eParticleSystemFlag_Pars ||
1144 emd->flag & eExplodeFlag_CalcFaces || facepa_array(emd)->size() != mesh->totface_legacy)
1145 {
1146 if (psmd->flag & eParticleSystemFlag_Pars) {
1148 }
1149 if (emd->flag & eExplodeFlag_CalcFaces) {
1151 }
1152 createFacepa(emd, psmd, mesh);
1153 }
1154 /* 2. create new mesh */
1156 if (emd->flag & eExplodeFlag_EdgeCut) {
1157 void *facepa = emd->facepa;
1158 Mesh *split_m = cutEdges(emd, mesh);
1159 Mesh *explode = explodeMesh(emd, psmd, ctx, scene, split_m);
1160
1161 MEM_delete(facepa_array(emd));
1162 emd->facepa = facepa;
1163 BKE_id_free(nullptr, split_m);
1164 return explode;
1165 }
1166
1167 return explodeMesh(emd, psmd, ctx, scene, mesh);
1168 }
1169 return mesh;
1170}
1171
1172static void panel_draw(const bContext * /*C*/, Panel *panel)
1173{
1174 ui::Layout &layout = *panel->layout;
1176
1177 PointerRNA ob_ptr;
1178 PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
1179
1180 PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
1181 bool has_vertex_group = RNA_string_length(ptr, "vertex_group") != 0;
1182
1183 layout.use_property_split_set(true);
1184
1185 layout.prop_search(ptr, "particle_uv", &obj_data_ptr, "uv_layers", std::nullopt, ICON_GROUP_UVS);
1186
1187 ui::Layout *row = &layout.row(true, IFACE_("Show"));
1188 row->prop(ptr, "show_alive", toggles_flag, std::nullopt, ICON_NONE);
1189 row->prop(ptr, "show_dead", toggles_flag, std::nullopt, ICON_NONE);
1190 row->prop(ptr, "show_unborn", toggles_flag, std::nullopt, ICON_NONE);
1191
1192 layout.use_property_split_set(true);
1193
1194 ui::Layout &col = layout.column(false);
1195 col.prop(ptr, "use_edge_cut", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1196 col.prop(ptr, "use_size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1197
1198 modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", std::nullopt);
1199
1200 row = &layout.row(false);
1201 row->active_set(has_vertex_group);
1202 row->prop(ptr, "protect", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1203
1204 layout.op("OBJECT_OT_explode_refresh", IFACE_("Refresh"), ICON_NONE);
1205
1206 modifier_error_message_draw(layout, ptr);
1207}
1208
1209static void panel_register(ARegionType *region_type)
1210{
1212}
1213
1214static void blend_read(BlendDataReader * /*reader*/, ModifierData *md)
1215{
1216 ExplodeModifierData *psmd = reinterpret_cast<ExplodeModifierData *>(md);
1217
1218 psmd->facepa = nullptr;
1219}
1220
1222 /*idname*/ "Explode",
1223 /*name*/ N_("Explode"),
1224 /*struct_name*/ "ExplodeModifierData",
1225 /*struct_size*/ sizeof(ExplodeModifierData),
1226 /*srna*/ &RNA_ExplodeModifier,
1229 /*icon*/ ICON_MOD_EXPLODE,
1230 /*copy_data*/ copy_data,
1231
1232 /*deform_verts*/ nullptr,
1233 /*deform_matrices*/ nullptr,
1234 /*deform_verts_EM*/ nullptr,
1235 /*deform_matrices_EM*/ nullptr,
1236 /*modify_mesh*/ modify_mesh,
1237 /*modify_geometry_set*/ nullptr,
1238
1239 /*init_data*/ init_data,
1240 /*required_data_mask*/ required_data_mask,
1241 /*free_data*/ free_data,
1242 /*is_disabled*/ nullptr,
1243 /*update_depsgraph*/ nullptr,
1244 /*depends_on_time*/ depends_on_time,
1245 /*depends_on_normals*/ nullptr,
1246 /*foreach_ID_link*/ nullptr,
1247 /*foreach_tex_link*/ nullptr,
1248 /*free_runtime_data*/ nullptr,
1249 /*panel_register*/ panel_register,
1250 /*blend_write*/ nullptr,
1251 /*blend_read*/ blend_read,
1252 /*foreach_cache*/ nullptr,
1253 /*foreach_working_space_color*/ nullptr,
1254};
1255
1256} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
support for deformation groups and hooks.
A KD-tree for nearest neighbor search.
Random number functions.
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define SET_VERTS(a, b, c, d)
#define GET_ES(v1, v2)
#define INT_UV(uvf, c0, c1)
#define UI_ITEM_NONE
#define CLAMP(a, b, c)
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define CD_MASK_MDEFORMVERT
const T * data() const
Definition BLI_array.hh:323
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
Value & lookup_or_add_cb(const Key &key, const CreateValueF &create_value)
Definition BLI_map.hh:620
ItemIterator items() const &
Definition BLI_map.hh:902
void copy(int src_index, int dst_index, int count) const
#define rot(x, k)
const int state
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
BMesh Iterators.
void kdtree_balance(KDTree< CoordT > *tree)
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
static void remap_uvs_15(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * CustomData_get_layer_n_for_write(CustomData *data, eCustomDataType type, int n, int totelem)
static int edgecut_get(const Map< OrderedEdge, int > &edgehash, uint v1, uint v2)
void psys_sim_data_init(struct ParticleSimulationData *sim)
Definition particle.cc:621
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static void remap_faces_15(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3, int v4)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra)
static bool depends_on_time(Scene *, ModifierData *)
Definition MOD_build.cc:46
MINLINE void copy_v2_v2(float r[2], const float a[2])
struct RNG * BLI_rng_new_srandom(unsigned int seed)
Definition rand.cc:48
static ParticleSystemModifierData * findPrecedingParticlesystem(Object *ob, ModifierData *emd)
ModifierTypeInfo modifierType_Explode
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
@ eModifierType_ParticleSystem
static void init_data(ModifierData *md)
static Mesh * cutEdges(ExplodeModifierData *emd, Mesh *mesh)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata_legacy, int mfindex, int nr)
static void remap_faces_23(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3)
MINLINE void mul_v3_fl(float r[3], float f)
void BKE_mesh_calc_edges_tessface(Mesh *mesh)
static void required_data_mask(ModifierData *, CustomData_MeshMasks *r_cddata_masks)
MINLINE void sub_v3_v3(float r[3], const float a[3])
void mul_qt_v3(const float q[4], float r[3])
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
Definition BLI_kdtree.hh:65
void mul_m4_v3(const float M[4][4], float r[3])
void modifier_error_message_draw(ui::Layout &layout, PointerRNA *ptr)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
Definition deform.cc:779
void modifier_vgroup_ui(ui::Layout &layout, PointerRNA *ptr, PointerRNA *ob_ptr, const StringRefNull vgroup_prop, const std::optional< StringRefNull > invert_vgroup_prop, const std::optional< StringRefNull > text)
static void remap_faces_5_10(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3, int v4)
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
Definition particle.cc:4930
void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
static void free_data(ModifierData *md)
static void remap_faces_19_21_22(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3)
static void panel_register(ARegionType *region_type)
static void remap_uvs_19_21_22(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2)
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
Definition BLI_kdtree.hh:96
int kdtree_find_nearest(const KDTree< CoordT > *tree, const CoordT &co, KDTreeNearest< CoordT > *r_nearest)
static void remap_uvs_5_10(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
static void remap_faces_7_11_13_14(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3, int v4)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition rand.cc:55
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
Definition MOD_array.cc:873
void BKE_id_free(Main *bmain, void *idv)
@ eModifierTypeFlag_AcceptsMesh
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition rand.cc:90
int RNA_string_length(PointerRNA *ptr, const char *name)
static MFace * get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
static void blend_read(BlendDataReader *, ModifierData *md)
static Array< int, 0 > * facepa_array(ExplodeModifierData *emd)
static Mesh * explodeMesh(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, const ModifierEvalContext *ctx, Scene *scene, Mesh *to_explode)
MINLINE void add_v3_v3(float r[3], const float a[3])
void kdtree_free(KDTree< CoordT > *tree)
Definition BLI_kdtree.hh:84
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2581
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, StringRef name, int totelem)
void BKE_mesh_tessface_ensure(Mesh *mesh)
static void remap_uvs_23(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2)
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])
Definition particle.cc:2285
static void remap_uvs_7_11_13_14(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
static void panel_draw(const bContext *, Panel *panel)
static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Mesh *mesh)
static void remap_faces_3_6_9_12(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, const Map< OrderedEdge, int > &eh, int cur, int v1, int v2, int v3, int v4)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
const CustomData_MeshMasks CD_MASK_EVERYTHING
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
static const short add_faces[24]
void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
void psys_sim_data_free(struct ParticleSimulationData *sim)
Definition particle.cc:662
static void remap_uvs_3_6_9_12(Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
Mesh * BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src, int verts_num, int edges_num, int tessface_num, int faces_num, int corners_num, CustomData_MeshMasks mask)
CustomData fdata_legacy
struct ModifierData * next
ListBaseT< ModifierData > modifiers
ui::Layout * layout
eParticle_AliveState alive
struct ParticleSystem * psys
struct ParticleSystemModifierData * psmd
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< StringRefNull > name, int icon, bool results_are_suggestions)
void use_property_split_set(bool is_sep)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
Layout & row(bool align)
#define N_(msgid)