Blender  V2.93
MOD_explode.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2005 by the Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "BLI_utildefines.h"
25 
26 #include "BLI_edgehash.h"
27 #include "BLI_kdtree.h"
28 #include "BLI_math.h"
29 #include "BLI_rand.h"
30 
31 #include "BLT_translation.h"
32 
33 #include "DNA_defaults.h"
34 #include "DNA_mesh_types.h"
35 #include "DNA_meshdata_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_scene_types.h"
38 #include "DNA_screen_types.h"
39 
40 #include "BKE_context.h"
41 #include "BKE_deform.h"
42 #include "BKE_lattice.h"
43 #include "BKE_lib_id.h"
44 #include "BKE_mesh.h"
45 #include "BKE_modifier.h"
46 #include "BKE_particle.h"
47 #include "BKE_scene.h"
48 #include "BKE_screen.h"
49 
50 #include "UI_interface.h"
51 #include "UI_resources.h"
52 
53 #include "BLO_read_write.h"
54 
55 #include "RNA_access.h"
56 
57 #include "DEG_depsgraph_query.h"
58 
59 #include "MEM_guardedalloc.h"
60 
61 #include "MOD_modifiertypes.h"
62 #include "MOD_ui_common.h"
63 
64 static void initData(ModifierData *md)
65 {
67 
69 
71 }
72 static void freeData(ModifierData *md)
73 {
75 
76  MEM_SAFE_FREE(emd->facepa);
77 }
78 static void copyData(const ModifierData *md, ModifierData *target, const int flag)
79 {
80 #if 0
81  const ExplodeModifierData *emd = (const ExplodeModifierData *)md;
82 #endif
83  ExplodeModifierData *temd = (ExplodeModifierData *)target;
84 
85  BKE_modifier_copydata_generic(md, target, flag);
86 
87  temd->facepa = NULL;
88 }
90 {
91  return true;
92 }
93 static void requiredDataMask(Object *UNUSED(ob),
94  ModifierData *md,
95  CustomData_MeshMasks *r_cddata_masks)
96 {
98 
99  if (emd->vgroup) {
100  r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
101  }
102 }
103 
105 {
106  ParticleSystem *psys = psmd->psys;
107  MFace *fa = NULL, *mface = NULL;
108  MVert *mvert = NULL;
109  ParticleData *pa;
110  KDTree_3d *tree;
111  RNG *rng;
112  float center[3], co[3];
113  int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0;
114  int i, p, v1, v2, v3, v4 = 0;
115  const bool invert_vgroup = (emd->flag & eExplodeFlag_INVERT_VGROUP) != 0;
116 
117  mvert = mesh->mvert;
118  mface = mesh->mface;
119  totvert = mesh->totvert;
120  totface = mesh->totface;
121  totpart = psmd->psys->totpart;
122 
123  rng = BLI_rng_new_srandom(psys->seed);
124 
125  if (emd->facepa) {
126  MEM_freeN(emd->facepa);
127  }
128  facepa = emd->facepa = MEM_calloc_arrayN(totface, sizeof(int), "explode_facepa");
129 
130  vertpa = MEM_calloc_arrayN(totvert, sizeof(int), "explode_vertpa");
131 
132  /* initialize all faces & verts to no particle */
133  for (i = 0; i < totface; i++) {
134  facepa[i] = totpart;
135  }
136  for (i = 0; i < totvert; i++) {
137  vertpa[i] = totpart;
138  }
139 
140  /* set protected verts */
141  if (emd->vgroup) {
143  if (dvert) {
144  const int defgrp_index = emd->vgroup - 1;
145  for (i = 0; i < totvert; i++, dvert++) {
146  float val = BLI_rng_get_float(rng);
147  val = (1.0f - emd->protect) * val + emd->protect * 0.5f;
148  const float weight = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dvert, defgrp_index) :
149  BKE_defvert_find_weight(dvert, defgrp_index);
150  if (val < weight) {
151  vertpa[i] = -1;
152  }
153  }
154  }
155  }
156 
157  /* make tree of emitter locations */
158  tree = BLI_kdtree_3d_new(totpart);
159  for (p = 0, pa = psys->particles; p < totpart; p++, pa++) {
161  psys->part->from,
162  pa->num,
163  pa->num_dmcache,
164  pa->fuv,
165  pa->foffset,
166  co,
167  NULL,
168  NULL,
169  NULL,
170  NULL);
171  BLI_kdtree_3d_insert(tree, p, co);
172  }
173  BLI_kdtree_3d_balance(tree);
174 
175  /* set face-particle-indexes to nearest particle to face center */
176  for (i = 0, fa = mface; i < totface; i++, fa++) {
177  add_v3_v3v3(center, mvert[fa->v1].co, mvert[fa->v2].co);
178  add_v3_v3(center, mvert[fa->v3].co);
179  if (fa->v4) {
180  add_v3_v3(center, mvert[fa->v4].co);
181  mul_v3_fl(center, 0.25);
182  }
183  else {
184  mul_v3_fl(center, 1.0f / 3.0f);
185  }
186 
187  p = BLI_kdtree_3d_find_nearest(tree, center, NULL);
188 
189  v1 = vertpa[fa->v1];
190  v2 = vertpa[fa->v2];
191  v3 = vertpa[fa->v3];
192  if (fa->v4) {
193  v4 = vertpa[fa->v4];
194  }
195 
196  if (v1 >= 0 && v2 >= 0 && v3 >= 0 && (fa->v4 == 0 || v4 >= 0)) {
197  facepa[i] = p;
198  }
199 
200  if (v1 >= 0) {
201  vertpa[fa->v1] = p;
202  }
203  if (v2 >= 0) {
204  vertpa[fa->v2] = p;
205  }
206  if (v3 >= 0) {
207  vertpa[fa->v3] = p;
208  }
209  if (fa->v4 && v4 >= 0) {
210  vertpa[fa->v4] = p;
211  }
212  }
213 
214  if (vertpa) {
215  MEM_freeN(vertpa);
216  }
217  BLI_kdtree_3d_free(tree);
218 
219  BLI_rng_free(rng);
220 }
221 
222 static int edgecut_get(EdgeHash *edgehash, uint v1, uint v2)
223 {
224  return POINTER_AS_INT(BLI_edgehash_lookup(edgehash, v1, v2));
225 }
226 
227 static const short add_faces[24] = {
228  0, 0, 0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 2, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2,
229 };
230 
231 static MFace *get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
232 {
233  MFace *df = &split->mface[cur];
234  CustomData_copy_data(&mesh->fdata, &split->fdata, i, cur, 1);
235  *df = *mf;
236  return df;
237 }
238 
239 #define SET_VERTS(a, b, c, d) \
240  { \
241  v[0] = mf->v##a; \
242  uv[0] = a - 1; \
243  v[1] = mf->v##b; \
244  uv[1] = b - 1; \
245  v[2] = mf->v##c; \
246  uv[2] = c - 1; \
247  v[3] = mf->v##d; \
248  uv[3] = d - 1; \
249  } \
250  (void)0
251 
252 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2)
253 #define INT_UV(uvf, c0, c1) mid_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1])
254 
256  Mesh *split,
257  MFace *mf,
258  int *facepa,
259  const int *vertpa,
260  int i,
261  EdgeHash *eh,
262  int cur,
263  int v1,
264  int v2,
265  int v3,
266  int v4)
267 {
268  MFace *df1 = get_dface(mesh, split, cur, i, mf);
269  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
270  MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
271 
272  facepa[cur] = vertpa[v1];
273  df1->v1 = v1;
274  df1->v2 = GET_ES(v1, v2);
275  df1->v3 = GET_ES(v2, v3);
276  df1->v4 = v3;
277  df1->flag |= ME_FACE_SEL;
278 
279  facepa[cur + 1] = vertpa[v2];
280  df2->v1 = GET_ES(v1, v2);
281  df2->v2 = v2;
282  df2->v3 = GET_ES(v2, v3);
283  df2->v4 = 0;
284  df2->flag &= ~ME_FACE_SEL;
285 
286  facepa[cur + 2] = vertpa[v1];
287  df3->v1 = v1;
288  df3->v2 = v3;
289  df3->v3 = v4;
290  df3->v4 = 0;
291  df3->flag &= ~ME_FACE_SEL;
292 }
293 
294 static void remap_uvs_3_6_9_12(
295  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
296 {
297  MTFace *mf, *df1, *df2, *df3;
298  int l;
299 
300  for (l = 0; l < numlayer; l++) {
301  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
302  df1 = mf + cur;
303  df2 = df1 + 1;
304  df3 = df1 + 2;
306  mf += i;
307 
308  copy_v2_v2(df1->uv[0], mf->uv[c0]);
309  INT_UV(df1->uv[1], c0, c1);
310  INT_UV(df1->uv[2], c1, c2);
311  copy_v2_v2(df1->uv[3], mf->uv[c2]);
312 
313  INT_UV(df2->uv[0], c0, c1);
314  copy_v2_v2(df2->uv[1], mf->uv[c1]);
315  INT_UV(df2->uv[2], c1, c2);
316 
317  copy_v2_v2(df3->uv[0], mf->uv[c0]);
318  copy_v2_v2(df3->uv[1], mf->uv[c2]);
319  copy_v2_v2(df3->uv[2], mf->uv[c3]);
320  }
321 }
322 
324  Mesh *split,
325  MFace *mf,
326  int *facepa,
327  const int *vertpa,
328  int i,
329  EdgeHash *eh,
330  int cur,
331  int v1,
332  int v2,
333  int v3,
334  int v4)
335 {
336  MFace *df1 = get_dface(mesh, split, cur, i, mf);
337  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
338 
339  facepa[cur] = vertpa[v1];
340  df1->v1 = v1;
341  df1->v2 = v2;
342  df1->v3 = GET_ES(v2, v3);
343  df1->v4 = GET_ES(v1, v4);
344  df1->flag |= ME_FACE_SEL;
345 
346  facepa[cur + 1] = vertpa[v3];
347  df2->v1 = GET_ES(v1, v4);
348  df2->v2 = GET_ES(v2, v3);
349  df2->v3 = v3;
350  df2->v4 = v4;
351  df2->flag |= ME_FACE_SEL;
352 }
353 
354 static void remap_uvs_5_10(
355  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
356 {
357  MTFace *mf, *df1, *df2;
358  int l;
359 
360  for (l = 0; l < numlayer; l++) {
361  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
362  df1 = mf + cur;
363  df2 = df1 + 1;
365  mf += i;
366 
367  copy_v2_v2(df1->uv[0], mf->uv[c0]);
368  copy_v2_v2(df1->uv[1], mf->uv[c1]);
369  INT_UV(df1->uv[2], c1, c2);
370  INT_UV(df1->uv[3], c0, c3);
371 
372  INT_UV(df2->uv[0], c0, c3);
373  INT_UV(df2->uv[1], c1, c2);
374  copy_v2_v2(df2->uv[2], mf->uv[c2]);
375  copy_v2_v2(df2->uv[3], mf->uv[c3]);
376  }
377 }
378 
379 static void remap_faces_15(Mesh *mesh,
380  Mesh *split,
381  MFace *mf,
382  int *facepa,
383  const int *vertpa,
384  int i,
385  EdgeHash *eh,
386  int cur,
387  int v1,
388  int v2,
389  int v3,
390  int v4)
391 {
392  MFace *df1 = get_dface(mesh, split, cur, i, mf);
393  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
394  MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
395  MFace *df4 = get_dface(mesh, split, cur + 3, i, mf);
396 
397  facepa[cur] = vertpa[v1];
398  df1->v1 = v1;
399  df1->v2 = GET_ES(v1, v2);
400  df1->v3 = GET_ES(v1, v3);
401  df1->v4 = GET_ES(v1, v4);
402  df1->flag |= ME_FACE_SEL;
403 
404  facepa[cur + 1] = vertpa[v2];
405  df2->v1 = GET_ES(v1, v2);
406  df2->v2 = v2;
407  df2->v3 = GET_ES(v2, v3);
408  df2->v4 = GET_ES(v1, v3);
409  df2->flag |= ME_FACE_SEL;
410 
411  facepa[cur + 2] = vertpa[v3];
412  df3->v1 = GET_ES(v1, v3);
413  df3->v2 = GET_ES(v2, v3);
414  df3->v3 = v3;
415  df3->v4 = GET_ES(v3, v4);
416  df3->flag |= ME_FACE_SEL;
417 
418  facepa[cur + 3] = vertpa[v4];
419  df4->v1 = GET_ES(v1, v4);
420  df4->v2 = GET_ES(v1, v3);
421  df4->v3 = GET_ES(v3, v4);
422  df4->v4 = v4;
423  df4->flag |= ME_FACE_SEL;
424 }
425 
426 static void remap_uvs_15(
427  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
428 {
429  MTFace *mf, *df1, *df2, *df3, *df4;
430  int l;
431 
432  for (l = 0; l < numlayer; l++) {
433  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
434  df1 = mf + cur;
435  df2 = df1 + 1;
436  df3 = df1 + 2;
437  df4 = df1 + 3;
439  mf += i;
440 
441  copy_v2_v2(df1->uv[0], mf->uv[c0]);
442  INT_UV(df1->uv[1], c0, c1);
443  INT_UV(df1->uv[2], c0, c2);
444  INT_UV(df1->uv[3], c0, c3);
445 
446  INT_UV(df2->uv[0], c0, c1);
447  copy_v2_v2(df2->uv[1], mf->uv[c1]);
448  INT_UV(df2->uv[2], c1, c2);
449  INT_UV(df2->uv[3], c0, c2);
450 
451  INT_UV(df3->uv[0], c0, c2);
452  INT_UV(df3->uv[1], c1, c2);
453  copy_v2_v2(df3->uv[2], mf->uv[c2]);
454  INT_UV(df3->uv[3], c2, c3);
455 
456  INT_UV(df4->uv[0], c0, c3);
457  INT_UV(df4->uv[1], c0, c2);
458  INT_UV(df4->uv[2], c2, c3);
459  copy_v2_v2(df4->uv[3], mf->uv[c3]);
460  }
461 }
462 
464  Mesh *split,
465  MFace *mf,
466  int *facepa,
467  const int *vertpa,
468  int i,
469  EdgeHash *eh,
470  int cur,
471  int v1,
472  int v2,
473  int v3,
474  int v4)
475 {
476  MFace *df1 = get_dface(mesh, split, cur, i, mf);
477  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
478  MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
479 
480  facepa[cur] = vertpa[v1];
481  df1->v1 = v1;
482  df1->v2 = GET_ES(v1, v2);
483  df1->v3 = GET_ES(v2, v3);
484  df1->v4 = GET_ES(v1, v4);
485  df1->flag |= ME_FACE_SEL;
486 
487  facepa[cur + 1] = vertpa[v2];
488  df2->v1 = GET_ES(v1, v2);
489  df2->v2 = v2;
490  df2->v3 = GET_ES(v2, v3);
491  df2->v4 = 0;
492  df2->flag &= ~ME_FACE_SEL;
493 
494  facepa[cur + 2] = vertpa[v4];
495  df3->v1 = GET_ES(v1, v4);
496  df3->v2 = GET_ES(v2, v3);
497  df3->v3 = v3;
498  df3->v4 = v4;
499  df3->flag |= ME_FACE_SEL;
500 }
501 
503  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
504 {
505  MTFace *mf, *df1, *df2, *df3;
506  int l;
507 
508  for (l = 0; l < numlayer; l++) {
509  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
510  df1 = mf + cur;
511  df2 = df1 + 1;
512  df3 = df1 + 2;
514  mf += i;
515 
516  copy_v2_v2(df1->uv[0], mf->uv[c0]);
517  INT_UV(df1->uv[1], c0, c1);
518  INT_UV(df1->uv[2], c1, c2);
519  INT_UV(df1->uv[3], c0, c3);
520 
521  INT_UV(df2->uv[0], c0, c1);
522  copy_v2_v2(df2->uv[1], mf->uv[c1]);
523  INT_UV(df2->uv[2], c1, c2);
524 
525  INT_UV(df3->uv[0], c0, c3);
526  INT_UV(df3->uv[1], c1, c2);
527  copy_v2_v2(df3->uv[2], mf->uv[c2]);
528  copy_v2_v2(df3->uv[3], mf->uv[c3]);
529  }
530 }
531 
533  Mesh *split,
534  MFace *mf,
535  int *facepa,
536  const int *vertpa,
537  int i,
538  EdgeHash *eh,
539  int cur,
540  int v1,
541  int v2,
542  int v3)
543 {
544  MFace *df1 = get_dface(mesh, split, cur, i, mf);
545  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
546 
547  facepa[cur] = vertpa[v1];
548  df1->v1 = v1;
549  df1->v2 = GET_ES(v1, v2);
550  df1->v3 = GET_ES(v1, v3);
551  df1->v4 = 0;
552  df1->flag &= ~ME_FACE_SEL;
553 
554  facepa[cur + 1] = vertpa[v2];
555  df2->v1 = GET_ES(v1, v2);
556  df2->v2 = v2;
557  df2->v3 = v3;
558  df2->v4 = GET_ES(v1, v3);
559  df2->flag |= ME_FACE_SEL;
560 }
561 
562 static void remap_uvs_19_21_22(
563  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2)
564 {
565  MTFace *mf, *df1, *df2;
566  int l;
567 
568  for (l = 0; l < numlayer; l++) {
569  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
570  df1 = mf + cur;
571  df2 = df1 + 1;
573  mf += i;
574 
575  copy_v2_v2(df1->uv[0], mf->uv[c0]);
576  INT_UV(df1->uv[1], c0, c1);
577  INT_UV(df1->uv[2], c0, c2);
578 
579  INT_UV(df2->uv[0], c0, c1);
580  copy_v2_v2(df2->uv[1], mf->uv[c1]);
581  copy_v2_v2(df2->uv[2], mf->uv[c2]);
582  INT_UV(df2->uv[3], c0, c2);
583  }
584 }
585 
586 static void remap_faces_23(Mesh *mesh,
587  Mesh *split,
588  MFace *mf,
589  int *facepa,
590  const int *vertpa,
591  int i,
592  EdgeHash *eh,
593  int cur,
594  int v1,
595  int v2,
596  int v3)
597 {
598  MFace *df1 = get_dface(mesh, split, cur, i, mf);
599  MFace *df2 = get_dface(mesh, split, cur + 1, i, mf);
600  MFace *df3 = get_dface(mesh, split, cur + 2, i, mf);
601 
602  facepa[cur] = vertpa[v1];
603  df1->v1 = v1;
604  df1->v2 = GET_ES(v1, v2);
605  df1->v3 = GET_ES(v2, v3);
606  df1->v4 = GET_ES(v1, v3);
607  df1->flag |= ME_FACE_SEL;
608 
609  facepa[cur + 1] = vertpa[v2];
610  df2->v1 = GET_ES(v1, v2);
611  df2->v2 = v2;
612  df2->v3 = GET_ES(v2, v3);
613  df2->v4 = 0;
614  df2->flag &= ~ME_FACE_SEL;
615 
616  facepa[cur + 2] = vertpa[v3];
617  df3->v1 = GET_ES(v1, v3);
618  df3->v2 = GET_ES(v2, v3);
619  df3->v3 = v3;
620  df3->v4 = 0;
621  df3->flag &= ~ME_FACE_SEL;
622 }
623 
624 static void remap_uvs_23(
625  Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2)
626 {
627  MTFace *mf, *df1, *df2;
628  int l;
629 
630  for (l = 0; l < numlayer; l++) {
631  mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l);
632  df1 = mf + cur;
633  df2 = df1 + 1;
635  mf += i;
636 
637  copy_v2_v2(df1->uv[0], mf->uv[c0]);
638  INT_UV(df1->uv[1], c0, c1);
639  INT_UV(df1->uv[2], c1, c2);
640  INT_UV(df1->uv[3], c0, c2);
641 
642  INT_UV(df2->uv[0], c0, c1);
643  copy_v2_v2(df2->uv[1], mf->uv[c1]);
644  INT_UV(df2->uv[2], c1, c2);
645 
646  INT_UV(df2->uv[0], c0, c2);
647  INT_UV(df2->uv[1], c1, c2);
648  copy_v2_v2(df2->uv[2], mf->uv[c2]);
649  }
650 }
651 
653 {
654  Mesh *split_m;
655  MFace *mf = NULL, *df1 = NULL;
656  MFace *mface = mesh->mface;
657  MVert *dupve, *mv;
658  EdgeHash *edgehash;
659  EdgeHashIterator *ehi;
660  int totvert = mesh->totvert;
661  int totface = mesh->totface;
662 
663  int *facesplit = MEM_calloc_arrayN(totface, sizeof(int), "explode_facesplit");
664  int *vertpa = MEM_calloc_arrayN(totvert, sizeof(int), "explode_vertpa2");
665  int *facepa = emd->facepa;
666  int *fs, totesplit = 0, totfsplit = 0, curdupface = 0;
667  int i, v1, v2, v3, v4, esplit, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */
668  uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */
669  int numlayer;
670  uint ed_v1, ed_v2;
671 
672  edgehash = BLI_edgehash_new(__func__);
673 
674  /* recreate vertpa from facepa calculation */
675  for (i = 0, mf = mface; i < totface; i++, mf++) {
676  vertpa[mf->v1] = facepa[i];
677  vertpa[mf->v2] = facepa[i];
678  vertpa[mf->v3] = facepa[i];
679  if (mf->v4) {
680  vertpa[mf->v4] = facepa[i];
681  }
682  }
683 
684  /* mark edges for splitting and how to split faces */
685  for (i = 0, mf = mface, fs = facesplit; i < totface; i++, mf++, fs++) {
686  v1 = vertpa[mf->v1];
687  v2 = vertpa[mf->v2];
688  v3 = vertpa[mf->v3];
689 
690  if (v1 != v2) {
691  BLI_edgehash_reinsert(edgehash, mf->v1, mf->v2, NULL);
692  (*fs) |= 1;
693  }
694 
695  if (v2 != v3) {
696  BLI_edgehash_reinsert(edgehash, mf->v2, mf->v3, NULL);
697  (*fs) |= 2;
698  }
699 
700  if (mf->v4) {
701  v4 = vertpa[mf->v4];
702 
703  if (v3 != v4) {
704  BLI_edgehash_reinsert(edgehash, mf->v3, mf->v4, NULL);
705  (*fs) |= 4;
706  }
707 
708  if (v1 != v4) {
709  BLI_edgehash_reinsert(edgehash, mf->v1, mf->v4, NULL);
710  (*fs) |= 8;
711  }
712 
713  /* mark center vertex as a fake edge split */
714  if (*fs == 15) {
715  BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, NULL);
716  }
717  }
718  else {
719  (*fs) |= 16; /* mark face as tri */
720 
721  if (v1 != v3) {
722  BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, NULL);
723  (*fs) |= 4;
724  }
725  }
726  }
727 
728  /* count splits & create indexes for new verts */
729  ehi = BLI_edgehashIterator_new(edgehash);
730  totesplit = totvert;
733  totesplit++;
734  }
736 
737  /* count new faces due to splitting */
738  for (i = 0, fs = facesplit; i < totface; i++, fs++) {
739  totfsplit += add_faces[*fs];
740  }
741 
742  split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, totface + totfsplit, 0, 0);
743 
744  numlayer = CustomData_number_of_layers(&split_m->fdata, CD_MTFACE);
745 
746  /* copy new faces & verts (is it really this painful with custom data??) */
747  for (i = 0; i < totvert; i++) {
748  MVert source;
749  MVert *dest;
750  source = mesh->mvert[i];
751  dest = &split_m->mvert[i];
752 
753  CustomData_copy_data(&mesh->vdata, &split_m->vdata, i, i, 1);
754  *dest = source;
755  }
756 
757  /* override original facepa (original pointer is saved in caller function) */
758 
759  /* BMESH_TODO, (totfsplit * 2) over allocation is used since the quads are
760  * later interpreted as tri's, for this to work right I think we probably
761  * have to stop using tessface - campbell */
762 
763  facepa = MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), "explode_facepa");
764  // memcpy(facepa, emd->facepa, totface*sizeof(int));
765  emd->facepa = facepa;
766 
767  /* create new verts */
768  ehi = BLI_edgehashIterator_new(edgehash);
770  BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2);
772  mv = &split_m->mvert[ed_v2];
773  dupve = &split_m->mvert[esplit];
774 
775  CustomData_copy_data(&split_m->vdata, &split_m->vdata, ed_v2, esplit, 1);
776 
777  *dupve = *mv;
778 
779  mv = &split_m->mvert[ed_v1];
780 
781  mid_v3_v3v3(dupve->co, dupve->co, mv->co);
782  }
784 
785  /* create new faces */
786  curdupface = 0; //=totface;
787  // curdupin=totesplit;
788  for (i = 0, fs = facesplit; i < totface; i++, fs++) {
789  mf = &mesh->mface[i];
790 
791  switch (*fs) {
792  case 3:
793  case 10:
794  case 11:
795  case 15:
796  SET_VERTS(1, 2, 3, 4);
797  break;
798  case 5:
799  case 6:
800  case 7:
801  SET_VERTS(2, 3, 4, 1);
802  break;
803  case 9:
804  case 13:
805  SET_VERTS(4, 1, 2, 3);
806  break;
807  case 12:
808  case 14:
809  SET_VERTS(3, 4, 1, 2);
810  break;
811  case 21:
812  case 23:
813  SET_VERTS(1, 2, 3, 4);
814  break;
815  case 19:
816  SET_VERTS(2, 3, 1, 4);
817  break;
818  case 22:
819  SET_VERTS(3, 1, 2, 4);
820  break;
821  }
822 
823  switch (*fs) {
824  case 3:
825  case 6:
826  case 9:
827  case 12:
829  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
830  if (numlayer) {
831  remap_uvs_3_6_9_12(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
832  }
833  break;
834  case 5:
835  case 10:
837  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
838  if (numlayer) {
839  remap_uvs_5_10(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
840  }
841  break;
842  case 15:
844  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
845  if (numlayer) {
846  remap_uvs_15(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
847  }
848  break;
849  case 7:
850  case 11:
851  case 13:
852  case 14:
854  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
855  if (numlayer) {
856  remap_uvs_7_11_13_14(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
857  }
858  break;
859  case 19:
860  case 21:
861  case 22:
863  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
864  if (numlayer) {
865  remap_uvs_19_21_22(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2]);
866  }
867  break;
868  case 23:
870  mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
871  if (numlayer) {
872  remap_uvs_23(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2]);
873  }
874  break;
875  case 0:
876  case 16:
877  df1 = get_dface(mesh, split_m, curdupface, i, mf);
878  facepa[curdupface] = vertpa[mf->v1];
879 
880  if (df1->v4) {
881  df1->flag |= ME_FACE_SEL;
882  }
883  else {
884  df1->flag &= ~ME_FACE_SEL;
885  }
886  break;
887  }
888 
889  curdupface += add_faces[*fs] + 1;
890  }
891 
892  for (i = 0; i < curdupface; i++) {
893  mf = &split_m->mface[i];
894  test_index_face(mf, &split_m->fdata, i, ((mf->flag & ME_FACE_SEL) ? 4 : 3));
895  }
896 
897  BLI_edgehash_free(edgehash, NULL);
898  MEM_freeN(facesplit);
899  MEM_freeN(vertpa);
900 
903 
904  return split_m;
905 }
908  const ModifierEvalContext *ctx,
909  Scene *scene,
910  Mesh *to_explode)
911 {
912  Mesh *explode, *mesh = to_explode;
913  MFace *mf = NULL, *mface;
914  /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */
916  ParticleData *pa = NULL, *pars = psmd->psys->particles;
917  ParticleKey state, birth;
918  EdgeHash *vertpahash;
919  EdgeHashIterator *ehi;
920  float *vertco = NULL, imat[4][4];
921  float rot[4];
922  float cfra;
923  /* float timestep; */
924  const int *facepa = emd->facepa;
925  int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0;
926  int i, v, u;
927  uint ed_v1, ed_v2, mindex = 0;
928  MTFace *mtface = NULL, *mtf;
929 
930  totface = mesh->totface;
931  totvert = mesh->totvert;
932  mface = mesh->mface;
933  totpart = psmd->psys->totpart;
934 
935  sim.depsgraph = ctx->depsgraph;
936  sim.scene = scene;
937  sim.ob = ctx->object;
938  sim.psys = psmd->psys;
939  sim.psmd = psmd;
940 
941  /* timestep = psys_get_timestep(&sim); */
942 
943  cfra = BKE_scene_frame_get(scene);
944 
945  /* hash table for vertice <-> particle relations */
946  vertpahash = BLI_edgehash_new(__func__);
947 
948  for (i = 0; i < totface; i++) {
949  if (facepa[i] != totpart) {
950  pa = pars + facepa[i];
951 
952  if ((pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) ||
953  (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) ||
954  (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0)) {
955  delface++;
956  continue;
957  }
958  }
959  else {
960  pa = NULL;
961  }
962 
963  /* do mindex + totvert to ensure the vertex index to be the first
964  * with BLI_edgehashIterator_getKey */
965  if (pa == NULL || cfra < pa->time) {
966  mindex = totvert + totpart;
967  }
968  else {
969  mindex = totvert + facepa[i];
970  }
971 
972  mf = &mface[i];
973 
974  /* set face vertices to exist in particle group */
975  BLI_edgehash_reinsert(vertpahash, mf->v1, mindex, NULL);
976  BLI_edgehash_reinsert(vertpahash, mf->v2, mindex, NULL);
977  BLI_edgehash_reinsert(vertpahash, mf->v3, mindex, NULL);
978  if (mf->v4) {
979  BLI_edgehash_reinsert(vertpahash, mf->v4, mindex, NULL);
980  }
981  }
982 
983  /* make new vertice indexes & count total vertices after duplication */
984  ehi = BLI_edgehashIterator_new(vertpahash);
987  totdup++;
988  }
990 
991  /* the final duplicated vertices */
992  explode = BKE_mesh_new_nomain_from_template(mesh, totdup, 0, totface - delface, 0, 0);
993 
994  mtface = CustomData_get_layer_named(&explode->fdata, CD_MTFACE, emd->uvname);
995 
996  /* getting back to object space */
997  invert_m4_m4(imat, ctx->object->obmat);
998 
1000 
1001  /* duplicate & displace vertices */
1002  ehi = BLI_edgehashIterator_new(vertpahash);
1004  MVert source;
1005  MVert *dest;
1006 
1007  /* get particle + vertex from hash */
1008  BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2);
1009  ed_v2 -= totvert;
1011 
1012  source = mesh->mvert[ed_v1];
1013  dest = &explode->mvert[v];
1014 
1015  CustomData_copy_data(&mesh->vdata, &explode->vdata, ed_v1, v, 1);
1016 
1017  *dest = source;
1018 
1019  if (ed_v2 != totpart) {
1020  /* get particle */
1021  pa = pars + ed_v2;
1022 
1023  psys_get_birth_coords(&sim, pa, &birth, 0, 0);
1024 
1025  state.time = cfra;
1026  psys_get_particle_state(&sim, ed_v2, &state, 1);
1027 
1028  vertco = explode->mvert[v].co;
1029  mul_m4_v3(ctx->object->obmat, vertco);
1030 
1031  sub_v3_v3(vertco, birth.co);
1032 
1033  /* apply rotation, size & location */
1034  sub_qt_qtqt(rot, state.rot, birth.rot);
1035  mul_qt_v3(rot, vertco);
1036 
1037  if (emd->flag & eExplodeFlag_PaSize) {
1038  mul_v3_fl(vertco, pa->size);
1039  }
1040 
1041  add_v3_v3(vertco, state.co);
1042 
1043  mul_m4_v3(imat, vertco);
1044  }
1045  else {
1046  pa = NULL;
1047  }
1048  }
1050 
1051  /*map new vertices to faces*/
1052  for (i = 0, u = 0; i < totface; i++) {
1053  MFace source;
1054  int orig_v4;
1055 
1056  if (facepa[i] != totpart) {
1057  pa = pars + facepa[i];
1058 
1059  if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) {
1060  continue;
1061  }
1062  if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) {
1063  continue;
1064  }
1065  if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) {
1066  continue;
1067  }
1068  }
1069  else {
1070  pa = NULL;
1071  }
1072 
1073  source = mesh->mface[i];
1074  mf = &explode->mface[u];
1075 
1076  orig_v4 = source.v4;
1077 
1078  /* Same as above in the first loop over mesh's faces. */
1079  if (pa == NULL || cfra < pa->time) {
1080  mindex = totvert + totpart;
1081  }
1082  else {
1083  mindex = totvert + facepa[i];
1084  }
1085 
1086  source.v1 = edgecut_get(vertpahash, source.v1, mindex);
1087  source.v2 = edgecut_get(vertpahash, source.v2, mindex);
1088  source.v3 = edgecut_get(vertpahash, source.v3, mindex);
1089  if (source.v4) {
1090  source.v4 = edgecut_get(vertpahash, source.v4, mindex);
1091  }
1092 
1093  CustomData_copy_data(&mesh->fdata, &explode->fdata, i, u, 1);
1094 
1095  *mf = source;
1096 
1097  /* override uv channel for particle age */
1098  if (mtface) {
1099  float age = (pa != NULL) ? (cfra - pa->time) / pa->lifetime : 0.0f;
1100  /* Clamp to this range to avoid flipping to the other side of the coordinates. */
1101  CLAMP(age, 0.001f, 0.999f);
1102 
1103  mtf = mtface + u;
1104 
1105  mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = age;
1106  mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = 0.5f;
1107  }
1108 
1109  test_index_face(mf, &explode->fdata, u, (orig_v4 ? 4 : 3));
1110  u++;
1111  }
1112 
1113  /* cleanup */
1114  BLI_edgehash_free(vertpahash, NULL);
1115 
1116  /* finalization */
1119  explode->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
1120 
1121  if (psmd->psys->lattice_deform_data) {
1123  psmd->psys->lattice_deform_data = NULL;
1124  }
1125 
1126  return explode;
1127 }
1128 
1130 {
1131  ModifierData *md;
1133 
1134  for (md = ob->modifiers.first; emd != md; md = md->next) {
1135  if (md->type == eModifierType_ParticleSystem) {
1136  psmd = (ParticleSystemModifierData *)md;
1137  }
1138  }
1139  return psmd;
1140 }
1142 {
1145 
1146  if (psmd) {
1147  ParticleSystem *psys = psmd->psys;
1148 
1149  if (psys == NULL || psys->totpart == 0) {
1150  return mesh;
1151  }
1152  if (psys->part == NULL || psys->particles == NULL) {
1153  return mesh;
1154  }
1155  if (psmd->mesh_final == NULL) {
1156  return mesh;
1157  }
1158 
1159  BKE_mesh_tessface_ensure(mesh); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
1160 
1161  /* 1. find faces to be exploded if needed */
1162  if (emd->facepa == NULL || psmd->flag & eParticleSystemFlag_Pars ||
1163  emd->flag & eExplodeFlag_CalcFaces ||
1164  MEM_allocN_len(emd->facepa) / sizeof(int) != mesh->totface) {
1165  if (psmd->flag & eParticleSystemFlag_Pars) {
1166  psmd->flag &= ~eParticleSystemFlag_Pars;
1167  }
1168  if (emd->flag & eExplodeFlag_CalcFaces) {
1169  emd->flag &= ~eExplodeFlag_CalcFaces;
1170  }
1171  createFacepa(emd, psmd, mesh);
1172  }
1173  /* 2. create new mesh */
1175  if (emd->flag & eExplodeFlag_EdgeCut) {
1176  int *facepa = emd->facepa;
1177  Mesh *split_m = cutEdges(emd, mesh);
1178  Mesh *explode = explodeMesh(emd, psmd, ctx, scene, split_m);
1179 
1180  MEM_freeN(emd->facepa);
1181  emd->facepa = facepa;
1182  BKE_id_free(NULL, split_m);
1183  return explode;
1184  }
1185 
1186  return explodeMesh(emd, psmd, ctx, scene, mesh);
1187  }
1188  return mesh;
1189 }
1190 
1191 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
1192 {
1193  uiLayout *row, *col;
1194  uiLayout *layout = panel->layout;
1195  int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
1196 
1197  PointerRNA ob_ptr;
1199 
1200  PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
1201  bool has_vertex_group = RNA_string_length(ptr, "vertex_group") != 0;
1202 
1203  uiLayoutSetPropSep(layout, true);
1204 
1205  uiItemPointerR(layout, ptr, "particle_uv", &obj_data_ptr, "uv_layers", NULL, ICON_NONE);
1206 
1207  row = uiLayoutRowWithHeading(layout, true, IFACE_("Show"));
1208  uiItemR(row, ptr, "show_alive", toggles_flag, NULL, ICON_NONE);
1209  uiItemR(row, ptr, "show_dead", toggles_flag, NULL, ICON_NONE);
1210  uiItemR(row, ptr, "show_unborn", toggles_flag, NULL, ICON_NONE);
1211 
1212  uiLayoutSetPropSep(layout, true);
1213 
1214  col = uiLayoutColumn(layout, false);
1215  uiItemR(col, ptr, "use_edge_cut", 0, NULL, ICON_NONE);
1216  uiItemR(col, ptr, "use_size", 0, NULL, ICON_NONE);
1217 
1218  modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
1219 
1220  row = uiLayoutRow(layout, false);
1221  uiLayoutSetActive(row, has_vertex_group);
1222  uiItemR(row, ptr, "protect", 0, NULL, ICON_NONE);
1223 
1224  uiItemO(layout, IFACE_("Refresh"), ICON_NONE, "OBJECT_OT_explode_refresh");
1225 
1226  modifier_panel_end(layout, ptr);
1227 }
1228 
1229 static void panelRegister(ARegionType *region_type)
1230 {
1232 }
1233 
1234 static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
1235 {
1237 
1238  psmd->facepa = NULL;
1239 }
1240 
1242  /* name */ "Explode",
1243  /* structName */ "ExplodeModifierData",
1244  /* structSize */ sizeof(ExplodeModifierData),
1245  /* srna */ &RNA_ExplodeModifier,
1246  /* type */ eModifierTypeType_Constructive,
1247  /* flags */ eModifierTypeFlag_AcceptsMesh,
1248  /* icon */ ICON_MOD_EXPLODE,
1249  /* copyData */ copyData,
1250 
1251  /* deformVerts */ NULL,
1252  /* deformMatrices */ NULL,
1253  /* deformVertsEM */ NULL,
1254  /* deformMatricesEM */ NULL,
1255  /* modifyMesh */ modifyMesh,
1256  /* modifyHair */ NULL,
1257  /* modifyGeometrySet */ NULL,
1258  /* modifyVolume */ NULL,
1259 
1260  /* initData */ initData,
1261  /* requiredDataMask */ requiredDataMask,
1262  /* freeData */ freeData,
1263  /* isDisabled */ NULL,
1264  /* updateDepsgraph */ NULL,
1265  /* dependsOnTime */ dependsOnTime,
1266  /* dependsOnNormals */ NULL,
1267  /* foreachIDLink */ NULL,
1268  /* foreachTexLink */ NULL,
1269  /* freeRuntimeData */ NULL,
1270  /* panelRegister */ panelRegister,
1271  /* blendWrite */ NULL,
1272  /* blendRead */ blendRead,
1273 };
int CustomData_number_of_layers(const struct CustomData *data, int type)
void * CustomData_get_layer_named(const struct CustomData *data, int type, const char *name)
Definition: customdata.c:3217
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
void * CustomData_get_layer(const struct CustomData *data, int type)
void CustomData_copy_data(const struct CustomData *source, struct CustomData *dest, int source_index, int dest_index, int count)
support for deformation groups and hooks.
float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
Definition: deform.c:632
void BKE_lattice_deform_data_destroy(struct LatticeDeformData *lattice_deform_data)
void BKE_id_free(struct Main *bmain, void *idv)
void BKE_mesh_calc_edges_tessface(struct Mesh *mesh)
struct Mesh * BKE_mesh_new_nomain_from_template(const struct Mesh *me_src, int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_tessface_ensure(struct Mesh *mesh)
Definition: mesh.c:1560
int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr)
Definition: mesh.c:1203
void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh)
@ eModifierTypeFlag_AcceptsMesh
Definition: BKE_modifier.h:80
void BKE_modifier_copydata_generic(const struct ModifierData *md, struct ModifierData *md_dst, const int flag)
@ eModifierTypeType_Constructive
Definition: BKE_modifier.h:61
struct LatticeDeformData * psys_create_lattice_deform_data(struct ParticleSimulationData *sim)
Definition: particle.c:696
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.c:2290
int psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, int always)
Definition: particle.c:4854
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra)
float BKE_scene_frame_get(const struct Scene *scene)
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
Definition: edgehash.c:244
BLI_INLINE void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1)
Definition: BLI_edgehash.h:93
BLI_INLINE bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
Definition: BLI_edgehash.h:89
bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val)
Definition: edgehash.c:289
EdgeHashIterator * BLI_edgehashIterator_new(EdgeHash *eh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: edgehash.c:471
EdgeHash * BLI_edgehash_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: edgehash.c:239
BLI_INLINE void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
Definition: BLI_edgehash.h:85
void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
Definition: edgehash.c:496
BLI_INLINE void * BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
Definition: BLI_edgehash.h:101
void * BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT
Definition: edgehash.c:325
BLI_INLINE void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
Definition: BLI_edgehash.h:109
A kd-tree for nearest neighbor search.
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
void mul_qt_v3(const float q[4], float r[3])
Definition: math_rotation.c:97
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:270
MINLINE void add_v3_v3(float r[3], const float a[3])
Random number functions.
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition: rand.cc:76
struct RNG * BLI_rng_new_srandom(unsigned int seed)
Definition: rand.cc:64
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: rand.cc:120
unsigned int uint
Definition: BLI_sys_types.h:83
#define POINTER_FROM_INT(i)
#define UNUSED(x)
#define POINTER_AS_INT(i)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define IFACE_(msgid)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define CD_MASK_NORMAL
#define CD_MASK_MDEFORMVERT
@ CD_MDEFORMVERT
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:44
@ ME_FACE_SEL
@ eParticleSystemFlag_Pars
@ eModifierType_ParticleSystem
@ eModifierType_Explode
struct ExplodeModifierData ExplodeModifierData
@ eExplodeFlag_CalcFaces
@ eExplodeFlag_Alive
@ eExplodeFlag_Dead
@ eExplodeFlag_EdgeCut
@ eExplodeFlag_INVERT_VGROUP
@ eExplodeFlag_PaSize
@ eExplodeFlag_Unborn
Object is a sort of wrapper for general info.
#define PARS_DEAD
#define PARS_ALIVE
#define PARS_UNBORN
NSNotificationCenter * center
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static MFace * get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
Definition: MOD_explode.c:231
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
Definition: MOD_explode.c:1234
static void remap_uvs_3_6_9_12(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
Definition: MOD_explode.c:294
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
Definition: MOD_explode.c:78
static Mesh * modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
Definition: MOD_explode.c:1141
static void remap_uvs_7_11_13_14(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
Definition: MOD_explode.c:502
static void remap_faces_23(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3)
Definition: MOD_explode.c:586
static int edgecut_get(EdgeHash *edgehash, uint v1, uint v2)
Definition: MOD_explode.c:222
static ParticleSystemModifierData * findPrecedingParticlesystem(Object *ob, ModifierData *emd)
Definition: MOD_explode.c:1129
static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Mesh *mesh)
Definition: MOD_explode.c:104
static void remap_faces_3_6_9_12(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4)
Definition: MOD_explode.c:255
#define SET_VERTS(a, b, c, d)
Definition: MOD_explode.c:239
static const short add_faces[24]
Definition: MOD_explode.c:227
static void remap_uvs_23(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2)
Definition: MOD_explode.c:624
static Mesh * cutEdges(ExplodeModifierData *emd, Mesh *mesh)
Definition: MOD_explode.c:652
#define GET_ES(v1, v2)
Definition: MOD_explode.c:252
ModifierTypeInfo modifierType_Explode
Definition: MOD_explode.c:1241
#define INT_UV(uvf, c0, c1)
Definition: MOD_explode.c:253
static void remap_uvs_5_10(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
Definition: MOD_explode.c:354
static bool dependsOnTime(ModifierData *UNUSED(md))
Definition: MOD_explode.c:89
static void remap_uvs_19_21_22(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2)
Definition: MOD_explode.c:562
static void remap_faces_15(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4)
Definition: MOD_explode.c:379
static void remap_faces_7_11_13_14(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4)
Definition: MOD_explode.c:463
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: MOD_explode.c:1191
static void initData(ModifierData *md)
Definition: MOD_explode.c:64
static void panelRegister(ARegionType *region_type)
Definition: MOD_explode.c:1229
static void remap_faces_5_10(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4)
Definition: MOD_explode.c:323
static Mesh * explodeMesh(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, const ModifierEvalContext *ctx, Scene *scene, Mesh *to_explode)
Definition: MOD_explode.c:906
static void remap_faces_19_21_22(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, const int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3)
Definition: MOD_explode.c:532
static void freeData(ModifierData *md)
Definition: MOD_explode.c:72
static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
Definition: MOD_explode.c:93
static void remap_uvs_15(Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3)
Definition: MOD_explode.c:426
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
void modifier_vgroup_ui(uiLayout *layout, PointerRNA *ptr, PointerRNA *ob_ptr, const char *vgroup_prop, const char *invert_vgroup_prop, const char *text)
Group RGB to Bright Vector Camera CLAMP
StructRNA RNA_ExplodeModifier
#define C
Definition: RandGen.cpp:39
uiLayout * uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *heading)
void uiLayoutSetActive(uiLayout *layout, bool active)
@ UI_ITEM_R_TOGGLE
@ UI_ITEM_R_FORCE_BLANK_DECORATE
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
double time
Scene scene
void * tree
#define rot(x, k)
uint col
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:46
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:40
static ulong state[N]
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition: abc_util.cc:115
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6562
int RNA_string_length(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6539
void * first
Definition: DNA_listBase.h:47
unsigned int v2
unsigned int v1
unsigned int v4
unsigned int v3
float uv[4][2]
float co[3]
int64_t cd_dirty_vert
struct MVert * mvert
int totvert
int totface
Mesh_Runtime runtime
struct CustomData vdata edata fdata
struct MFace * mface
struct ModifierData * next
struct Depsgraph * depsgraph
Definition: BKE_modifier.h:153
struct Object * object
Definition: BKE_modifier.h:154
ListBase modifiers
float obmat[4][4]
struct uiLayout * layout
struct Depsgraph * depsgraph
Definition: BKE_particle.h:87
struct ParticleSystemModifierData * psmd
Definition: BKE_particle.h:91
struct Scene * scene
Definition: BKE_particle.h:88
struct ParticleSystem * psys
Definition: BKE_particle.h:90
struct Object * ob
Definition: BKE_particle.h:89
struct ParticleSystem * psys
ParticleData * particles
ParticleSettings * part
struct LatticeDeformData * lattice_deform_data
Definition: rand.cc:48
PointerRNA * ptr
Definition: wm_files.c:3157