Blender V5.3
particle_object.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10#include <cstring>
11
12#include "MEM_guardedalloc.h"
13
14#include "DNA_mesh_types.h"
15#include "DNA_meshdata_types.h"
16#include "DNA_modifier_types.h"
17#include "DNA_scene_types.h"
18
19#include "BLI_listbase.hh"
20#include "BLI_math_geom_c.hh"
21#include "BLI_math_matrix_c.hh"
22#include "BLI_math_vector_c.hh"
23#include "BLI_string_utf8.hh"
24#include "BLI_utildefines.hh"
25
26#include "BKE_bvh.hh"
27#include "BKE_bvhutils.hh"
28#include "BKE_context.hh"
29#include "BKE_customdata.hh"
30#include "BKE_global.hh"
31#include "BKE_layer.hh"
32#include "BKE_lib_id.hh"
33#include "BKE_library.hh"
34#include "BKE_mesh.hh"
36#include "BKE_modifier.hh"
37#include "BKE_object.hh"
38#include "BKE_particle.h"
39#include "BKE_pointcache.h"
40#include "BKE_report.hh"
41
42#include "DEG_depsgraph.hh"
45
46#include "RNA_access.hh"
47#include "RNA_define.hh"
48#include "RNA_prototypes.hh"
49
50#include "WM_api.hh"
51#include "WM_types.hh"
52
53#include "ED_object.hh"
54#include "ED_particle.hh"
55#include "ED_screen.hh"
56
58
59#include "physics_intern.hh"
60
61namespace blender {
62
63static float I[4][4] = {
64 {1.0f, 0.0f, 0.0f, 0.0f},
65 {0.0f, 1.0f, 0.0f, 0.0f},
66 {0.0f, 0.0f, 1.0f, 0.0f},
67 {0.0f, 0.0f, 0.0f, 1.0f},
68};
69
70/********************** particle system slot operators *********************/
71
73{
74 Main *bmain = CTX_data_main(C);
76 Scene *scene = CTX_data_scene(C);
77
78 if (!scene || !ob) {
79 return OPERATOR_CANCELLED;
80 }
81
82 object_add_particle_system(bmain, scene, ob, nullptr);
83
86
87 return OPERATOR_FINISHED;
88}
89
91{
92 /* identifiers */
93 ot->name = "Add Particle System Slot";
94 ot->idname = "OBJECT_OT_particle_system_add";
95 ot->description = "Add a particle system";
96
97 /* API callbacks. */
100
101 /* flags */
103}
104
106{
107 Main *bmain = CTX_data_main(C);
109 Scene *scene = CTX_data_scene(C);
110 ViewLayer *view_layer = CTX_data_view_layer(C);
111 int mode_orig;
112
113 if (!scene || !ob) {
114 return OPERATOR_CANCELLED;
115 }
116
117 mode_orig = ob->mode;
119 object_remove_particle_system(bmain, scene, ob, psys);
120
121 /* possible this isn't the active object
122 * object_remove_particle_system() clears the mode on the last psys
123 */
124 if (mode_orig & OB_MODE_PARTICLE_EDIT) {
125 if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
126 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
127 if (BKE_view_layer_active_object_get(view_layer) == ob) {
129 }
130 }
131 }
132
135
136 return OPERATOR_FINISHED;
137}
138
140{
141 /* identifiers */
142 ot->name = "Remove Particle System Slot";
143 ot->idname = "OBJECT_OT_particle_system_remove";
144 ot->description = "Remove the selected particle system";
145
146 /* API callbacks. */
149
150 /* flags */
152}
153
154/********************** new particle settings operator *********************/
155
156static bool psys_poll(bContext *C)
157{
158 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
159 return ptr;
160}
161
163{
164 Main *bmain = CTX_data_main(C);
165 ParticleSystem *psys;
166 ParticleSettings *part = nullptr;
167 Object *ob;
168 PointerRNA ptr;
169
170 ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
171
172 psys = static_cast<ParticleSystem *>(ptr.data);
173
174 /* add or copy particle setting */
175 if (psys->part) {
176 part = reinterpret_cast<ParticleSettings *>(BKE_id_copy_ex(
177 bmain, &psys->part->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS));
178 }
179 else {
180 part = BKE_particlesettings_add(bmain, "ParticleSettings");
181 }
182
183 ob = id_cast<Object *>(ptr.owner_id);
184
185 if (psys->part) {
186 id_us_min(&psys->part->id);
187 }
188
189 psys->part = part;
190
192
195
197
198 return OPERATOR_FINISHED;
199}
200
202{
203 /* identifiers */
204 ot->name = "New Particle Settings";
205 ot->idname = "PARTICLE_OT_new";
206 ot->description = "Add new particle settings";
207
208 /* API callbacks. */
210 ot->poll = psys_poll;
211
212 /* flags */
214}
215
216/********************** keyed particle target operators *********************/
217
219{
220 Main *bmain = CTX_data_main(C);
221 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
222 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
223 Object *ob = id_cast<Object *>(ptr.owner_id);
224
225 ParticleTarget *pt;
226
227 if (!psys) {
228 return OPERATOR_CANCELLED;
229 }
230
231 pt = psys->targets.first();
232 for (; pt; pt = pt->next) {
233 pt->flag &= ~PTARGET_CURRENT;
234 }
235
236 pt = MEM_new<ParticleTarget>("keyed particle target");
237
238 pt->flag |= PTARGET_CURRENT;
239 pt->psys = 1;
240
241 BLI_addtail(&psys->targets, pt);
242
245
247
248 return OPERATOR_FINISHED;
249}
250
252{
253 /* identifiers */
254 ot->name = "New Particle Target";
255 ot->idname = "PARTICLE_OT_new_target";
256 ot->description = "Add a new particle target";
257
258 /* API callbacks. */
260
261 /* flags */
263}
264
266{
267 Main *bmain = CTX_data_main(C);
268 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
269 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
270 Object *ob = id_cast<Object *>(ptr.owner_id);
271
272 ParticleTarget *pt;
273
274 if (!psys) {
275 return OPERATOR_CANCELLED;
276 }
277
278 pt = psys->targets.first();
279 for (; pt; pt = pt->next) {
280 if (pt->flag & PTARGET_CURRENT) {
281 BLI_remlink(&psys->targets, pt);
282 MEM_delete(pt);
283 break;
284 }
285 }
286 pt = psys->targets.last();
287
288 if (pt) {
289 pt->flag |= PTARGET_CURRENT;
290 }
291
294
296
297 return OPERATOR_FINISHED;
298}
299
301{
302 /* identifiers */
303 ot->name = "Remove Particle Target";
304 ot->idname = "PARTICLE_OT_target_remove";
305 ot->description = "Remove the selected particle target";
306
307 /* API callbacks. */
309
310 /* flags */
312}
313
314/************************ move up particle target operator *********************/
315
317{
318 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
319 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
320 Object *ob = id_cast<Object *>(ptr.owner_id);
321 ParticleTarget *pt;
322
323 if (!psys) {
324 return OPERATOR_CANCELLED;
325 }
326
327 pt = psys->targets.first();
328 for (; pt; pt = pt->next) {
329 if (pt->flag & PTARGET_CURRENT && pt->prev) {
330 BLI_remlink(&psys->targets, pt);
331 BLI_insertlinkbefore(&psys->targets, pt->prev, pt);
332
335 break;
336 }
337 }
338
339 return OPERATOR_FINISHED;
340}
341
343{
344 ot->name = "Move Up Target";
345 ot->idname = "PARTICLE_OT_target_move_up";
346 ot->description = "Move particle target up in the list";
347
349
350 /* flags */
352}
353
354/************************ move down particle target operator *********************/
355
357{
358 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
359 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
360 Object *ob = id_cast<Object *>(ptr.owner_id);
361 ParticleTarget *pt;
362
363 if (!psys) {
364 return OPERATOR_CANCELLED;
365 }
366 pt = psys->targets.first();
367 for (; pt; pt = pt->next) {
368 if (pt->flag & PTARGET_CURRENT && pt->next) {
369 BLI_remlink(&psys->targets, pt);
370 BLI_insertlinkafter(&psys->targets, pt->next, pt);
371
374 break;
375 }
376 }
377
378 return OPERATOR_FINISHED;
379}
380
382{
383 ot->name = "Move Down Target";
384 ot->idname = "PARTICLE_OT_target_move_down";
385 ot->description = "Move particle target down in the list";
386
388
389 /* flags */
391}
392
393/************************ refresh dupli objects *********************/
394
396{
397 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
398 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
399
400 if (!psys) {
401 return OPERATOR_CANCELLED;
402 }
403
407
408 return OPERATOR_FINISHED;
409}
410
412{
413 ot->name = "Refresh Instance Objects";
414 ot->idname = "PARTICLE_OT_dupliob_refresh";
415 ot->description = "Refresh list of instance objects and their weights";
416
418
419 /* flags */
421}
422
423/************************ move up particle dupli-weight operator *********************/
424
426{
427 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
428 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
429 ParticleSettings *part;
430
431 if (!psys) {
432 return OPERATOR_CANCELLED;
433 }
434
435 part = psys->part;
436 for (ParticleDupliWeight &dw : part->instance_weights) {
437 if (dw.flag & PART_DUPLIW_CURRENT && dw.prev) {
438 BLI_remlink(&part->instance_weights, &dw);
440
443 break;
444 }
445 }
446
447 return OPERATOR_FINISHED;
448}
449
451{
452 ot->name = "Move Up Instance Object";
453 ot->idname = "PARTICLE_OT_dupliob_move_up";
454 ot->description = "Move instance object up in the list";
455
457
458 /* flags */
460}
461
462/********************** particle dupliweight operators *********************/
463
465{
466 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
467 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
468 ParticleSettings *part;
469
470 if (!psys) {
471 return OPERATOR_CANCELLED;
472 }
473 part = psys->part;
474 for (ParticleDupliWeight &dw : part->instance_weights) {
475 if (dw.flag & PART_DUPLIW_CURRENT) {
477
478 ParticleDupliWeight *new_dw = MEM_dupalloc(&dw);
479 new_dw->flag |= PART_DUPLIW_CURRENT;
480 BLI_addhead(&part->instance_weights, new_dw);
481
484 break;
485 }
486 }
487
488 return OPERATOR_FINISHED;
489}
490
492{
493 /* identifiers */
494 ot->name = "Copy Particle Instance Object";
495 ot->idname = "PARTICLE_OT_dupliob_copy";
496 ot->description = "Duplicate the current instance object";
497
498 /* API callbacks. */
500
501 /* flags */
503}
504
506{
507 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
508 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
509 ParticleSettings *part;
510
511 if (!psys) {
512 return OPERATOR_CANCELLED;
513 }
514
515 part = psys->part;
516 for (ParticleDupliWeight &dw : part->instance_weights) {
517 if (dw.flag & PART_DUPLIW_CURRENT) {
518 BLI_remlink(&part->instance_weights, &dw);
519 MEM_delete(&dw);
520 break;
521 }
522 }
523
524 ParticleDupliWeight *dw = part->instance_weights.last();
525 if (dw) {
527 }
528
531
532 return OPERATOR_FINISHED;
533}
534
536{
537 /* identifiers */
538 ot->name = "Remove Particle Instance Object";
539 ot->idname = "PARTICLE_OT_dupliob_remove";
540 ot->description = "Remove the selected instance object";
541
542 /* API callbacks. */
544
545 /* flags */
547}
548
549/************************ move down particle dupliweight operator *********************/
550
552{
553 PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem);
554 ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
555 ParticleSettings *part;
556
557 if (!psys) {
558 return OPERATOR_CANCELLED;
559 }
560
561 part = psys->part;
562 for (ParticleDupliWeight &dw : part->instance_weights) {
563 if (dw.flag & PART_DUPLIW_CURRENT && dw.next) {
564 BLI_remlink(&part->instance_weights, &dw);
566
569 break;
570 }
571 }
572
573 return OPERATOR_FINISHED;
574}
575
577{
578 ot->name = "Move Down Instance Object";
579 ot->idname = "PARTICLE_OT_dupliob_move_down";
580 ot->description = "Move instance object down in the list";
581
583
584 /* flags */
586}
587
588/************************ connect/disconnect hair operators *********************/
589
590static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
591{
592 Object *object_eval = DEG_get_evaluated(depsgraph, ob);
593 ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
594 ParticleSystemModifierData *psmd_eval = psys_get_modifier(object_eval, psys_eval);
595 ParticleEditSettings *pset = PE_settings(scene);
596 ParticleData *pa;
597 PTCacheEdit *edit;
598 PTCacheEditPoint *point;
599 PTCacheEditKey *ekey = nullptr;
600 HairKey *key;
601 int i, k;
602 float hairmat[4][4];
603
604 if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) {
605 return;
606 }
607
608 if (!psys->part || psys->part->type != PART_HAIR) {
609 return;
610 }
611
612 edit = psys->edit;
613 point = edit ? edit->points : nullptr;
614
615 for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
616 if (point) {
617 ekey = point->keys;
618 point++;
619 }
620
621 psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, pa, hairmat);
622
623 for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) {
624 mul_m4_v3(hairmat, key->co);
625
626 if (ekey) {
627 ekey->flag &= ~PEK_USE_WCO;
628 ekey++;
629 }
630 }
631 }
632
633 psys_free_path_cache(psys, psys->edit);
634
635 psys->flag |= PSYS_GLOBAL_HAIR;
636
638 pset->brushtype = PE_BRUSH_COMB;
639 }
640
641 PE_update_object(depsgraph, scene, ob, 0);
642}
643
645{
646 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
647 Scene *scene = CTX_data_scene(C);
649 ParticleSystem *psys = nullptr;
650 const bool all = RNA_boolean_get(op->ptr, "all");
651
652 if (!ob) {
653 return OPERATOR_CANCELLED;
654 }
655
656 if (all) {
657 for (ParticleSystem &psys : ob->particlesystem) {
658 disconnect_hair(depsgraph, scene, ob, &psys);
659 }
660 }
661 else {
662 psys = psys_get_current(ob);
663 disconnect_hair(depsgraph, scene, ob, psys);
664 }
665
668
669 return OPERATOR_FINISHED;
670}
671
673{
674 ot->name = "Disconnect Hair";
675 ot->description = "Disconnect hair from the emitter mesh";
676 ot->idname = "PARTICLE_OT_disconnect_hair";
677
679
680 /* flags */
681 /* No REGISTER, redo does not work due to missing update, see #47750. */
682 ot->flag = OPTYPE_UNDO;
683
685 ot->srna, "all", false, "All Hair", "Disconnect all hair systems from the emitter mesh");
686}
687
688/* from/to_world_space : whether from/to particles are in world or hair space
689 * from/to_mat : additional transform for from/to particles (e.g. for using object space copying)
690 */
691static bool remap_hair_emitter(Depsgraph *depsgraph,
692 Scene *scene,
693 Object *ob,
694 ParticleSystem *psys,
695 Object *target_ob,
696 ParticleSystem *target_psys,
697 PTCacheEdit *target_edit,
698 const float from_mat[4][4],
699 const float to_mat[4][4],
700 bool from_global,
701 bool to_global)
702{
703 Object *object_eval = DEG_get_evaluated(depsgraph, ob);
704 ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
705 ParticleSystemModifierData *target_psmd = psys_get_modifier(object_eval, psys_eval);
706 ParticleData *pa, *tpa;
707 PTCacheEditPoint *edit_point;
708 PTCacheEditKey *ekey;
709 bke::BVHTreeFromMesh legacy_faces_bvhtree = {nullptr};
710 const bke::bvh::Tree *edges_tree = nullptr;
711 const MFace *mface = nullptr, *mf;
712 const int2 *edges = nullptr, *edge;
713 Mesh *mesh, *target_mesh;
714 int numverts;
715 int k;
716 float from_ob_imat[4][4], to_ob_imat[4][4];
717 float from_imat[4][4], to_imat[4][4];
718
719 if (!target_psmd->mesh_final) {
720 return false;
721 }
722 if (!psys->part || psys->part->type != PART_HAIR) {
723 return false;
724 }
725 if (!target_psys->part || target_psys->part->type != PART_HAIR) {
726 return false;
727 }
728
729 edit_point = target_edit ? target_edit->points : nullptr;
730
731 invert_m4_m4(from_ob_imat, ob->object_to_world().ptr());
732 invert_m4_m4(to_ob_imat, target_ob->object_to_world().ptr());
733 invert_m4_m4(from_imat, from_mat);
734 invert_m4_m4(to_imat, to_mat);
735
736 const bool use_dm_final_indices = (target_psys->part->use_modifier_stack &&
737 !target_psmd->mesh_final->runtime->deformed_only);
738
739 if (use_dm_final_indices || !target_psmd->mesh_original) {
740 mesh = target_psmd->mesh_final;
741 }
742 else {
743 mesh = target_psmd->mesh_original;
744 }
745 target_mesh = target_psmd->mesh_final;
746 if (mesh == nullptr) {
747 return false;
748 }
749 /* don't modify the original vertices */
750 /* we don't want to mess up target_psmd->dm when converting to global coordinates below */
751 mesh = id_cast<Mesh *>(BKE_id_copy_ex(nullptr, &mesh->id, nullptr, LIB_ID_COPY_LOCALIZE));
752
753 /* BMESH_ONLY, deform dm may not have tessface */
755
756 numverts = mesh->verts_num;
757 MutableSpan<float3> positions = mesh->vert_positions_for_write();
758
759 /* convert to global coordinates */
760 for (int i = 0; i < numverts; i++) {
761 mul_m4_v3(to_mat, positions[i]);
762 }
763
764 if (mesh->totface_legacy != 0) {
765 mface = static_cast<const MFace *>(CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE));
766 legacy_faces_bvhtree = mesh->bvh_legacy_faces();
767 }
768 else if (mesh->edges_num != 0) {
769 edges = mesh->edges().data();
770 edges_tree = &mesh->bvh_edges();
771 }
772 else {
773 BKE_id_free(nullptr, mesh);
774 return false;
775 }
776
777 int i;
778 for (i = 0, tpa = target_psys->particles, pa = psys->particles; i < target_psys->totpart;
779 i++, tpa++, pa++)
780 {
781 float from_co[3];
782
783 if (from_global) {
784 mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].co);
785 }
786 else {
787 mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].world_co);
788 }
789 mul_m4_v3(from_mat, from_co);
790
791 int nearest_index = -1;
792 float3 nearest_co;
793 if (mface) {
794 BVHTreeNearest nearest;
795 nearest.index = -1;
796 nearest.dist_sq = FLT_MAX;
797 BLI_bvhtree_find_nearest(legacy_faces_bvhtree.tree,
798 from_co,
799 &nearest,
800 legacy_faces_bvhtree.nearest_callback,
801 &legacy_faces_bvhtree);
802 nearest_index = nearest.index;
803 nearest_co = float3(nearest.co);
804 }
805 else if (const std::optional<bke::bvh::ClosestPointResult> nearest = edges_tree->closest_point(
806 float3(from_co)))
807 {
808 nearest_index = int(nearest->index);
809 nearest_co = nearest->position;
810 }
811
812 if (nearest_index == -1) {
813 if (G.debug & G_DEBUG) {
814 printf("No nearest point found for hair root!");
815 }
816 continue;
817 }
818
819 if (mface) {
820 float v[4][3];
821
822 mf = &mface[nearest_index];
823
824 copy_v3_v3(v[0], positions[mf->v1]);
825 copy_v3_v3(v[1], positions[mf->v2]);
826 copy_v3_v3(v[2], positions[mf->v3]);
827 if (mf->v4) {
828 copy_v3_v3(v[3], positions[mf->v4]);
829 interp_weights_poly_v3(tpa->fuv, v, 4, nearest_co);
830 }
831 else {
832 interp_weights_poly_v3(tpa->fuv, v, 3, nearest_co);
833 }
834 tpa->foffset = 0.0f;
835
836 tpa->num = nearest_index;
837 if (use_dm_final_indices) {
839 }
840 else {
842 target_psmd->mesh_final, target_psmd->mesh_original, tpa->num, tpa->fuv, nullptr);
843 }
844 }
845 else {
846 edge = &edges[nearest_index];
847
848 tpa->fuv[1] = line_point_factor_v3(nearest_co, positions[edge->x], positions[edge->y]);
849 tpa->fuv[0] = 1.0f - tpa->fuv[1];
850 tpa->fuv[2] = tpa->fuv[3] = 0.0f;
851 tpa->foffset = 0.0f;
852
853 tpa->num = nearest_index;
854 tpa->num_dmcache = -1;
855 }
856
857 /* translate hair keys */
858 {
859 HairKey *key, *tkey;
860 float hairmat[4][4], imat[4][4];
861 float offset[3];
862
863 if (to_global) {
864 copy_m4_m4(imat, target_ob->object_to_world().ptr());
865 }
866 else {
867 /* NOTE: using target_dm here, which is in target_ob object space and has full modifiers.
868 */
869 psys_mat_hair_to_object(target_ob, target_mesh, target_psys->part->from, tpa, hairmat);
870 invert_m4_m4(imat, hairmat);
871 }
872 mul_m4_m4m4(imat, imat, to_imat);
873
874 /* offset in world space */
875 sub_v3_v3v3(offset, nearest_co, from_co);
876
877 if (edit_point) {
878 for (k = 0, key = pa->hair, tkey = tpa->hair, ekey = edit_point->keys; k < tpa->totkey;
879 k++, key++, tkey++, ekey++)
880 {
881 float co_orig[3];
882
883 if (from_global) {
884 mul_v3_m4v3(co_orig, from_ob_imat, key->co);
885 }
886 else {
887 mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
888 }
889 mul_m4_v3(from_mat, co_orig);
890
891 add_v3_v3v3(tkey->co, co_orig, offset);
892
893 mul_m4_v3(imat, tkey->co);
894
895 ekey->flag |= PEK_USE_WCO;
896 }
897
898 edit_point++;
899 }
900 else {
901 for (k = 0, key = pa->hair, tkey = tpa->hair; k < tpa->totkey; k++, key++, tkey++) {
902 float co_orig[3];
903
904 if (from_global) {
905 mul_v3_m4v3(co_orig, from_ob_imat, key->co);
906 }
907 else {
908 mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
909 }
910 mul_m4_v3(from_mat, co_orig);
911
912 add_v3_v3v3(tkey->co, co_orig, offset);
913
914 mul_m4_v3(imat, tkey->co);
915 }
916 }
917 }
918 }
919
920 BKE_id_free(nullptr, mesh);
921
922 psys_free_path_cache(target_psys, target_edit);
923
924 PE_update_object(depsgraph, scene, target_ob, 0);
925
926 return true;
927}
928
929static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
930{
931 bool ok;
932
933 if (!psys) {
934 return false;
935 }
936
937 ok = remap_hair_emitter(depsgraph,
938 scene,
939 ob,
940 psys,
941 ob,
942 psys,
943 psys->edit,
944 ob->object_to_world().ptr(),
945 ob->object_to_world().ptr(),
946 psys->flag & PSYS_GLOBAL_HAIR,
947 false);
948 if (ok) {
949 psys->flag &= ~PSYS_GLOBAL_HAIR;
950 }
951
952 return ok;
953}
954
956{
957 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
958 Scene *scene = CTX_data_scene(C);
960 ParticleSystem *psys = nullptr;
961 const bool all = RNA_boolean_get(op->ptr, "all");
962 bool any_connected = false;
963
964 if (!ob) {
965 return OPERATOR_CANCELLED;
966 }
967
968 if (all) {
969 for (ParticleSystem &psys : ob->particlesystem) {
970 any_connected |= connect_hair(depsgraph, scene, ob, &psys);
971 }
972 }
973 else {
974 psys = psys_get_current(ob);
975 any_connected |= connect_hair(depsgraph, scene, ob, psys);
976 }
977
978 if (!any_connected) {
981 "No hair connected (cannot connect hair if particle system modifier is disabled)");
982 return OPERATOR_CANCELLED;
983 }
984
987
988 return OPERATOR_FINISHED;
989}
990
992{
993 ot->name = "Connect Hair";
994 ot->description = "Connect hair to the emitter mesh";
995 ot->idname = "PARTICLE_OT_connect_hair";
996
998
999 /* flags */
1000 /* No REGISTER, redo does not work due to missing update, see #47750. */
1001 ot->flag = OPTYPE_UNDO;
1002
1004 ot->srna, "all", false, "All Hair", "Connect all hair systems to the emitter mesh");
1005}
1006
1007/************************ particle system copy operator *********************/
1008
1013
1014static void copy_particle_edit(Depsgraph *depsgraph,
1015 Scene *scene,
1016 Object *ob,
1017 ParticleSystem *psys,
1018 ParticleSystem *psys_from)
1019{
1020 PTCacheEdit *edit_from = psys_from->edit, *edit;
1021 ParticleData *pa;
1022 KEY_K;
1023 POINT_P;
1024
1025 if (!edit_from) {
1026 return;
1027 }
1028
1029 edit = MEM_dupalloc(edit_from);
1030 edit->psys = psys;
1031 psys->edit = edit;
1032
1033 edit->pathcache = nullptr;
1034 edit->mirror_cache = nullptr;
1035 edit->pathcachebufs.clear_no_delete();
1036
1037 edit->emitter_field = nullptr;
1038 edit->emitter_cosnos = nullptr;
1039
1040 edit->points = MEM_dupalloc(edit_from->points);
1041 pa = psys->particles;
1042 LOOP_POINTS {
1043 HairKey *hkey = pa->hair;
1044
1045 point->keys = MEM_dupalloc(point->keys);
1046 LOOP_KEYS {
1047 key->co = hkey->co;
1048 key->time = &hkey->time;
1049 key->flag = hkey->editflag;
1050 if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
1051 key->flag |= PEK_USE_WCO;
1052 hkey->editflag |= PEK_USE_WCO;
1053 }
1054
1055 hkey++;
1056 }
1057
1058 pa++;
1059 }
1060 update_world_cos(ob, edit);
1061
1062 recalc_lengths(edit);
1063 recalc_emitter_field(depsgraph, ob, psys);
1064 PE_update_object(depsgraph, scene, ob, true);
1065}
1066
1068{
1069 ModifierData *md, *md_next;
1070
1071 if (ob_to->type != OB_MESH) {
1072 return;
1073 }
1074 if (!ob_to->data || !ID_IS_EDITABLE(ob_to->data) || ID_IS_OVERRIDE_LIBRARY(ob_to->data)) {
1075 return;
1076 }
1077
1078 for (md = ob_to->modifiers.first(); md; md = md_next) {
1079 md_next = md->next;
1080
1081 /* remove all particle system modifiers as well,
1082 * these need to sync to the particle system list
1083 */
1084 if (ELEM(md->type,
1088 {
1089 BLI_remlink(&ob_to->modifiers, md);
1091 }
1092 }
1093
1095}
1096
1097/* single_psys_from is optional, if nullptr all psys of ob_from are copied */
1099 Scene *scene,
1100 Object *ob_from,
1101 ParticleSystem *single_psys_from,
1102 Object *ob_to,
1103 int space,
1104 bool duplicate_settings)
1105{
1106 Main *bmain = CTX_data_main(C);
1107 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
1108 ModifierData *md;
1109 ParticleSystem *psys_start = nullptr, *psys, *psys_from;
1110 ParticleSystem **tmp_psys;
1111 CustomData_MeshMasks cdmask = {0};
1112 int i, totpsys;
1113
1114 if (ob_to->type != OB_MESH) {
1115 return false;
1116 }
1117 if (!ob_to->data || !BKE_id_is_editable(bmain, static_cast<const ID *>(ob_to->data))) {
1118 return false;
1119 }
1120
1121/* For remapping we need a valid DM.
1122 * Because the modifiers are appended at the end it's safe to use
1123 * the final DM of the object without particles.
1124 * However, when evaluating the DM all the particle modifiers must be valid,
1125 * i.e. have the psys assigned already.
1126 *
1127 * To break this hen/egg problem we create all psys separately first
1128 * (to collect required customdata masks),
1129 * then create the DM, then add them to the object and make the psys modifiers.
1130 */
1131#define PSYS_FROM_FIRST \
1132 static_cast<ParticleSystem *>( \
1133 (single_psys_from ? single_psys_from : ob_from->particlesystem.first()))
1134#define PSYS_FROM_NEXT(cur) (single_psys_from ? nullptr : (cur)->next)
1135 totpsys = single_psys_from ? 1 : ob_from->particlesystem.count();
1136
1138 "temporary particle system array");
1139
1140 for (psys_from = PSYS_FROM_FIRST, i = 0; psys_from; psys_from = PSYS_FROM_NEXT(psys_from), i++) {
1141 psys = BKE_object_copy_particlesystem(psys_from, 0);
1142 tmp_psys[i] = psys;
1143
1144 if (psys_start == nullptr) {
1145 psys_start = psys;
1146 }
1147
1148 psys_emitter_customdata_mask(psys, &cdmask);
1149 }
1150 /* to iterate source and target psys in sync,
1151 * we need to know where the newly added psys start
1152 */
1153 psys_start = totpsys > 0 ? tmp_psys[0] : nullptr;
1154
1155 /* now append psys to the object and make modifiers */
1156 for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; ++i, psys_from = PSYS_FROM_NEXT(psys_from))
1157 {
1159
1160 psys = tmp_psys[i];
1161
1162 /* append to the object */
1163 BLI_addtail(&ob_to->particlesystem, psys);
1164 psys_unique_name(ob_to, psys, psys->name);
1165
1166 /* add a particle system modifier for each system */
1168 psmd = reinterpret_cast<ParticleSystemModifierData *>(md);
1169 /* push on top of the stack, no use trying to reproduce old stack order */
1172
1173 SNPRINTF_UTF8(md->name, "ParticleSystem %i", i);
1174 BKE_modifier_unique_name(&ob_to->modifiers, reinterpret_cast<ModifierData *>(psmd));
1175
1176 psmd->psys = psys;
1177
1178 if (psys_from->edit) {
1179 copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from);
1180 }
1181
1182 if (duplicate_settings) {
1183 id_us_min(&psys->part->id);
1184 psys->part = id_cast<ParticleSettings *>(BKE_id_copy(bmain, &psys->part->id));
1185 }
1186 }
1187 MEM_delete(tmp_psys);
1188
1189 /* NOTE: do this after creating DM copies for all the particle system modifiers,
1190 * the remapping otherwise makes final_dm invalid!
1191 */
1192 for (psys = psys_start, psys_from = PSYS_FROM_FIRST, i = 0; psys;
1193 psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), i++)
1194 {
1195 const float (*from_mat)[4], (*to_mat)[4];
1196
1197 switch (space) {
1199 from_mat = I;
1200 to_mat = I;
1201 break;
1203 from_mat = ob_from->object_to_world().ptr();
1204 to_mat = ob_to->object_to_world().ptr();
1205 break;
1206 default:
1207 /* should not happen */
1208 from_mat = to_mat = nullptr;
1209 BLI_assert(false);
1210 break;
1211 }
1212 if (ob_from != ob_to) {
1213 remap_hair_emitter(depsgraph,
1214 scene,
1215 ob_from,
1216 psys_from,
1217 ob_to,
1218 psys,
1219 psys->edit,
1220 from_mat,
1221 to_mat,
1222 psys_from->flag & PSYS_GLOBAL_HAIR,
1223 psys->flag & PSYS_GLOBAL_HAIR);
1224 }
1225
1226 /* tag for recalc */
1227 // psys->recalc |= ID_RECALC_PSYS_RESET;
1228 }
1229
1230#undef PSYS_FROM_FIRST
1231#undef PSYS_FROM_NEXT
1232
1236 return true;
1237}
1238
1240{
1241 Object *ob;
1243 return false;
1244 }
1245
1247 if (ob->particlesystem.is_empty()) {
1248 return false;
1249 }
1250
1251 return true;
1252}
1253
1255{
1256 const int space = RNA_enum_get(op->ptr, "space");
1257 const bool remove_target_particles = RNA_boolean_get(op->ptr, "remove_target_particles");
1258 const bool use_active = RNA_boolean_get(op->ptr, "use_active");
1259 Scene *scene = CTX_data_scene(C);
1261
1262 ParticleSystem *psys_from = nullptr;
1263 if (use_active) {
1264 psys_from = static_cast<ParticleSystem *>(
1265 CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem).data);
1266 if (psys_from == nullptr) {
1267 /* Particle System context pointer is only valid in the Properties Editor. */
1268 psys_from = psys_get_current(ob_from);
1269 }
1270 }
1271
1272 int changed_tot = 0;
1273 int fail = 0;
1274
1275 CTX_DATA_BEGIN (C, Object *, ob_to, selected_editable_objects) {
1276 if (ob_from != ob_to) {
1277 bool changed = false;
1278 if (remove_target_particles) {
1280 changed = true;
1281 }
1282 if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false)) {
1283 changed = true;
1284 }
1285 else {
1286 fail++;
1287 }
1288
1289 if (changed) {
1290 changed_tot++;
1291 }
1292 }
1293 }
1295
1296 if (changed_tot > 0) {
1298 }
1299
1300 if ((changed_tot == 0 && fail == 0) || fail) {
1301 BKE_reportf(op->reports,
1302 RPT_ERROR,
1303 "Copy particle systems to selected: %d done, %d failed",
1304 changed_tot,
1305 fail);
1306 }
1307
1308 return OPERATOR_FINISHED;
1309}
1310
1312{
1313 static const EnumPropertyItem space_items[] = {
1314 {PAR_COPY_SPACE_OBJECT, "OBJECT", 0, "Object", "Copy inside each object's local space"},
1315 {PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"},
1316 {0, nullptr, 0, nullptr, nullptr},
1317 };
1318
1319 ot->name = "Copy Particle Systems";
1320 ot->description = "Copy particle systems from the active object to selected objects";
1321 ot->idname = "PARTICLE_OT_copy_particle_systems";
1322
1325
1326 /* flags */
1328
1329 RNA_def_enum(ot->srna,
1330 "space",
1331 space_items,
1333 "Space",
1334 "Space transform for copying from one object to another");
1336 "remove_target_particles",
1337 true,
1338 "Remove Target Particles",
1339 "Remove particle systems on the target objects");
1341 "use_active",
1342 false,
1343 "Use Active",
1344 "Use the active particle system from the context");
1345}
1346
1348{
1350 return false;
1351 }
1353 if (ob->particlesystem.is_empty()) {
1354 return false;
1355 }
1356 if (ob->mode != OB_MODE_OBJECT) {
1357 CTX_wm_operator_poll_msg_set(C, "Object must be in object mode");
1358 return false;
1359 }
1360 return true;
1361}
1362
1364{
1365 const bool duplicate_settings = RNA_boolean_get(op->ptr, "use_duplicate_settings");
1366 Scene *scene = CTX_data_scene(C);
1368 /* Context pointer is only valid in the Properties Editor. */
1369 ParticleSystem *psys = static_cast<ParticleSystem *>(
1370 CTX_data_pointer_get_type(C, "particle_system", RNA_ParticleSystem).data);
1371 if (psys == nullptr) {
1372 psys = psys_get_current(ob);
1373 }
1374
1376 C, scene, ob, psys, ob, PAR_COPY_SPACE_OBJECT, duplicate_settings);
1377 return OPERATOR_FINISHED;
1378}
1379
1381{
1382 ot->name = "Duplicate Particle System";
1383 ot->description = "Duplicate particle system within the active object";
1384 ot->idname = "PARTICLE_OT_duplicate_particle_system";
1385
1388
1389 /* flags */
1391
1393 "use_duplicate_settings",
1394 false,
1395 "Duplicate Settings",
1396 "Duplicate settings as well, so the new particle system uses its own settings");
1397}
1398
1400{
1402 return false;
1403 }
1405 if (ob->particlesystem.is_empty()) {
1406 return false;
1407 }
1408 if (ob->mode != OB_MODE_OBJECT) {
1409 CTX_wm_operator_poll_msg_set(C, "Object must be in object mode");
1410 return false;
1411 }
1412 return true;
1413}
1415{
1416 Main *bmain = CTX_data_main(C);
1418 Scene *scene = CTX_data_scene(C);
1419 ViewLayer *view_layer = CTX_data_view_layer(C);
1420
1421 if (!scene || !ob) {
1422 return OPERATOR_CANCELLED;
1423 }
1424
1425 const eObjectMode mode_orig = ob->mode;
1426 for (ParticleSystem &psys : ob->particlesystem.items_mutable()) {
1427 object_remove_particle_system(bmain, scene, ob, &psys);
1428 }
1429
1430 /* possible this isn't the active object
1431 * object_remove_particle_system() clears the mode on the last psys
1432 */
1433 if (mode_orig & OB_MODE_PARTICLE_EDIT) {
1434 if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
1435 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1436 if (BKE_view_layer_active_object_get(view_layer) == ob) {
1438 }
1439 }
1440 }
1441
1444
1445 return OPERATOR_FINISHED;
1446}
1447
1449{
1450 ot->name = "Remove All Particle Systems";
1451 ot->description = "Remove all particle system within the active object";
1452 ot->idname = "PARTICLE_OT_particle_system_remove_all";
1453
1456
1457 /* flags */
1459}
1460
1461} // namespace blender
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_END
CustomData interface, see also DNA_customdata_types.h.
General operations, lookup, etc. for blender objects.
#define DMCACHE_ISCHILD
#define PEK_USE_WCO
#define SNPRINTF_UTF8(dst, format,...)
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define ND_MODE
Definition WM_types.hh:464
#define NC_SCENE
Definition WM_types.hh:391
#define NA_EDITED
Definition WM_types.hh:634
#define ND_PARTICLE
Definition WM_types.hh:506
#define NS_MODE_OBJECT
Definition WM_types.hh:610
#define ND_POINTCACHE
Definition WM_types.hh:507
#define NC_OBJECT
Definition WM_types.hh:392
#define ELEM(...)
std::optional< ClosestPointResult > closest_point(const float3 &point, float radius=std::numeric_limits< float >::max()) const
Definition bvh.cc:709
#define FLT_MAX
bool all(VecOp< bool, D >) RET
Object * context_object(const bContext *C)
Object * context_active_object(const bContext *C)
BMesh Iterators.
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit)
Definition particle.cc:938
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
struct ModifierData * object_add_particle_system(struct Main *bmain, const struct Scene *scene, struct Object *ob, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
Definition particle.cc:4031
static void remove_particle_systems_from_object(Object *ob_to)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
@ RPT_WARNING
Definition BKE_report.hh:40
static wmOperatorStatus particle_system_remove_all_exec(bContext *C, wmOperator *)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
struct ParticleSystem * psys_get_current(struct Object *ob)
Definition particle.cc:571
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
static bool copy_particle_systems_poll(bContext *C)
void OBJECT_OT_particle_system_add(wmOperatorType *ot)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void BKE_object_free_particlesystems(Object *ob)
Definition object.cc:1311
static wmOperatorStatus target_move_up_exec(bContext *C, wmOperator *)
static void copy_particle_edit(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
@ eModifierType_ParticleSystem
@ eModifierType_DynamicPaint
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus dupliob_move_down_exec(bContext *C, wmOperator *)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void PARTICLE_OT_connect_hair(wmOperatorType *ot)
ATTR_WARN_UNUSED_RESULT const BMVert * v
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
Definition particle.cc:2190
bool ED_operator_object_active_local_editable(bContext *C)
static bool psys_poll(bContext *C)
void PARTICLE_OT_dupliob_remove(wmOperatorType *ot)
struct ParticleSettings * BKE_particlesettings_add(struct Main *bmain, const char *name)
Definition particle.cc:4135
static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
void BKE_modifiers_persistent_uid_init(const Object &object, ModifierData &md)
@ LIB_ID_COPY_LOCALIZE
@ LIB_ID_COPY_DEFAULT
@ LIB_ID_COPY_ACTIONS
ViewLayer * CTX_data_view_layer(const bContext *C)
void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
static bool duplicate_particle_systems_poll(bContext *C)
static bool remove_all_particle_systems_poll(bContext *C)
Global G
Definition blender.cc:57
void BKE_modifier_unique_name(ListBaseT< ModifierData > *modifiers, ModifierData *md)
void mul_m4_v3(const float M[4][4], float r[3])
void PARTICLE_OT_particle_system_remove_all(wmOperatorType *ot)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void recalc_lengths(PTCacheEdit *edit)
VecBase< int32_t, 2 > int2
void PARTICLE_OT_new(wmOperatorType *ot)
void recalc_emitter_field(Depsgraph *, Object *, ParticleSystem *psys)
static wmOperatorStatus connect_hair_exec(bContext *C, wmOperator *op)
static wmOperatorStatus new_particle_settings_exec(bContext *C, wmOperator *)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
static wmOperatorStatus copy_particle_systems_exec(bContext *C, wmOperator *op)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ OB_MODE_PARTICLE_EDIT
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void psys_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
Definition particle.cc:2246
void BKE_modifiers_add_at_end_if_possible(Object *ob, ModifierData *new_md)
static wmOperatorStatus dupliob_move_up_exec(bContext *C, wmOperator *)
ModifierData * BKE_modifier_new(int type)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
static wmOperatorStatus copy_particle_dupliob_exec(bContext *C, wmOperator *)
static wmOperatorStatus remove_particle_target_exec(bContext *C, wmOperator *)
static wmOperatorStatus particle_system_remove_exec(bContext *C, wmOperator *)
void BKE_modifier_free(ModifierData *md)
void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot)
void PARTICLE_OT_target_move_down(wmOperatorType *ot)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void psys_mat_hair_to_object(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
Definition particle.cc:3888
void PARTICLE_OT_dupliob_refresh(wmOperatorType *ot)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void interp_weights_poly_v3(float w[], float v[][3], int n, const float co[3])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
static wmOperatorStatus duplicate_particle_systems_exec(bContext *C, wmOperator *op)
void BKE_id_free(Main *bmain, void *idv)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:378
void PARTICLE_OT_target_remove(wmOperatorType *ot)
void PARTICLE_OT_target_move_up(wmOperatorType *ot)
static wmOperatorStatus dupliob_refresh_exec(bContext *C, wmOperator *)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
static wmOperatorStatus particle_system_add_exec(bContext *C, wmOperator *)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void PARTICLE_OT_duplicate_particle_system(wmOperatorType *ot)
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
Definition particle.cc:3944
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static bool copy_particle_systems_to_object(const bContext *C, Scene *scene, Object *ob_from, ParticleSystem *single_psys_from, Object *ob_to, int space, bool duplicate_settings)
Main * CTX_data_main(const bContext *C)
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)
Definition particle.cc:1869
static wmOperatorStatus new_particle_target_exec(bContext *C, wmOperator *)
@ ID_RECALC_PSYS_REDO
Definition DNA_ID.h:1081
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
void update_world_cos(Object *ob, PTCacheEdit *edit)
static wmOperatorStatus remove_particle_dupliob_exec(bContext *C, wmOperator *)
void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
void BKE_mesh_tessface_ensure(Mesh *mesh)
static wmOperatorStatus target_move_down_exec(bContext *C, wmOperator *)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
ParticleSystem * BKE_object_copy_particlesystem(ParticleSystem *psys, int flag)
Definition object.cc:2374
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:851
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
void psys_check_group_weights(struct ParticleSettings *part)
Definition particle.cc:795
void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot)
ID * BKE_id_copy(Main *bmain, const ID *id)
Definition lib_id.cc:856
void id_us_min(ID *id)
Definition lib_id.cc:441
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
Definition particle.cc:697
void PARTICLE_OT_dupliob_copy(wmOperatorType *ot)
static bool remap_hair_emitter(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit, const float from_mat[4][4], const float to_mat[4][4], bool from_global, bool to_global)
void PARTICLE_OT_new_target(wmOperatorType *ot)
void psys_check_boid_data(struct ParticleSystem *psys)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
ParticleEditSettings * PE_settings(Scene *scene)
static wmOperatorStatus disconnect_hair_exec(bContext *C, wmOperator *op)
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname) ATTR_NONNULL(1
#define I
#define POINT_P
#define LOOP_KEYS
#define KEY_K
#define LOOP_POINTS
#define PSYS_FROM_FIRST
#define PSYS_FROM_NEXT(cur)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::MeshRuntime * runtime
struct ModifierData * next
ListBaseT< ModifierData > modifiers
ListBaseT< struct ParticleSystem > particlesystem
struct PTCacheEditKey * keys
PTCacheEditPoint * points
struct ParticleCacheKey ** pathcache
struct ParticleDupliWeight * prev
struct ParticleDupliWeight * next
eParticleDupliWeight_Flag flag
ListBaseT< ParticleDupliWeight > instance_weights
struct PTCacheEdit * edit
ListBaseT< ParticleTarget > targets
eParticleSystem_Flag flag
struct ParticleTarget * prev
eParticleTarget_Flag flag
struct ParticleTarget * next
BVHTree_NearestPointCallback nearest_callback
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
struct ReportList * reports
CCL_NAMESPACE_BEGIN ccl_device_inline T to_global(const float2 p, const T X, const T Y)
Definition transform.h:21