Blender V5.3
MOD_particleinstance.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "MEM_guardedalloc.h"
10
11#include "BLI_color_types.hh"
12#include "BLI_listbase.hh"
13#include "BLI_math_matrix_c.hh"
15#include "BLI_math_vector_c.hh"
16#include "BLI_rand_c.hh"
17#include "BLI_utildefines.hh"
18
19#include "BLT_translation.hh"
20
21#include "DNA_mesh_types.h"
22#include "DNA_meshdata_types.h"
23#include "DNA_screen_types.h"
24
26#include "BKE_customdata.hh"
27#include "BKE_lib_query.hh"
28#include "BKE_mesh.hh"
29#include "BKE_modifier.hh"
30#include "BKE_particle.h"
31#include "BKE_pointcache.h"
32
34#include "UI_resources.hh"
35
36#include "RNA_access.hh"
37#include "RNA_prototypes.hh"
38
41
42#include "MOD_ui_common.hh"
43
44namespace blender {
45
46static void init_data(ModifierData *md)
47{
48 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
50}
51
52static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
53{
54 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
55
56 if (pimd->index_layer_name[0] != '\0' || pimd->value_layer_name[0] != '\0') {
57 r_cddata_masks->lmask |= CD_MASK_PROP_BYTE_COLOR;
58 }
59}
60
61static bool is_disabled(const Scene *scene, ModifierData *md, bool use_render_params)
62{
63 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
64 ParticleSystem *psys;
65
66 /* The object type check is only needed here in case we have a placeholder
67 * object assigned (because the library containing the mesh is missing).
68 *
69 * In other cases it should be impossible to have a type mismatch.
70 */
71 if (!pimd->ob || pimd->ob->type != OB_MESH) {
72 return true;
73 }
74
75 psys = static_cast<ParticleSystem *>(BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1));
76 if (psys == nullptr) {
77 return true;
78 }
79
80 /* If the psys modifier is disabled we cannot use its data.
81 * First look up the psys modifier from the object, then check if it is enabled.
82 */
83 for (ModifierData &ob_md : pimd->ob->modifiers) {
85 ParticleSystemModifierData *psmd = reinterpret_cast<ParticleSystemModifierData *>(&ob_md);
86 if (psmd->psys == psys) {
87 int required_mode;
88
89 if (use_render_params) {
90 required_mode = eModifierMode_Render;
91 }
92 else {
93 required_mode = eModifierMode_Realtime;
94 }
95
96 if (!BKE_modifier_is_enabled(scene, &ob_md, required_mode)) {
97 return true;
98 }
99
100 break;
101 }
102 }
103 }
104
105 return false;
106}
107
109{
110 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
111 if (pimd->ob != nullptr) {
113 ctx->node, pimd->ob, DEG_OB_COMP_TRANSFORM, "Particle Instance Modifier");
115 ctx->node, pimd->ob, DEG_OB_COMP_GEOMETRY, "Particle Instance Modifier");
116 }
117}
118
119static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
120{
121 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
122
123 walk(user_data, ob, reinterpret_cast<ID **>(&pimd->ob), IDWALK_CB_NOP);
124}
125
127{
128 const bool between = (psys->part->childtype == PART_CHILD_FACES);
129 ParticleData *pa;
130 int totpart, randp, minp, maxp;
131
132 if (p >= psys->totpart) {
133 ChildParticle *cpa = psys->child + (p - psys->totpart);
134 pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
135 }
136 else {
137 pa = psys->particles + p;
138 }
139
140 if (pa) {
141 if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) {
142 return true;
143 }
144 if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) {
145 return true;
146 }
147 if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) {
148 return true;
149 }
150 if (pa->flag & (PARS_UNEXIST | PARS_NO_DISP)) {
151 return true;
152 }
153 }
154
155 if (pimd->particle_amount == 1.0f) {
156 /* Early output, all particles are to be instanced. */
157 return false;
158 }
159
160 /* Randomly skip particles based on desired amount of visible particles. */
161
162 totpart = psys->totpart + psys->totchild;
163
164 /* TODO: make randomization optional? */
165 randp = int(psys_frand(psys, 3578 + p) * totpart) % totpart;
166
167 minp = int(totpart * pimd->particle_offset) % (totpart + 1);
168 maxp = int(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart + 1);
169
170 if (maxp > minp) {
171 return randp < minp || randp >= maxp;
172 }
173 if (maxp < minp) {
174 return randp < minp && randp >= maxp;
175 }
176
177 return true;
178}
179
180static void store_float_in_vcol(ColorGeometry4b *vcol, float float_value)
181{
182 const uchar value = unit_float_to_uchar_clamp(float_value);
183 vcol->r = vcol->g = vcol->b = value;
184 vcol->a = 1.0f;
185}
186
188{
189 Mesh *result;
190 ParticleInstanceModifierData *pimd = reinterpret_cast<ParticleInstanceModifierData *>(md);
193 ParticleSystem *psys = nullptr;
194 ParticleData *pa = nullptr;
195 int totvert, faces_num, totloop, totedge;
196 int maxvert, maxpoly, maxloop, maxedge, part_end = 0, part_start;
197 int k, p, p_skip;
198 const uint track = uint(ctx->object->trackflag) % 3;
199 short trackneg, axis = pimd->axis;
200 float max_co = 0.0, min_co = 0.0, temp_co[3];
201 float *size = nullptr;
202 float spacemat[4][4];
203 const bool use_parents = pimd->flag & eParticleInstanceFlag_Parents;
204 const bool use_children = pimd->flag & eParticleInstanceFlag_Children;
205 bool between;
206
207 trackneg = ((ctx->object->trackflag > 2) ? 1 : 0);
208
209 if (pimd->ob == ctx->object) {
210 pimd->ob = nullptr;
211 return mesh;
212 }
213
214 if (pimd->ob) {
215 psys = static_cast<ParticleSystem *>(BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1));
216 if (psys == nullptr || psys->totpart == 0) {
217 return mesh;
218 }
219 }
220 else {
221 return mesh;
222 }
223
224 part_start = use_parents ? 0 : psys->totpart;
225
226 part_end = 0;
227 if (use_parents) {
228 part_end += psys->totpart;
229 }
230 if (use_children) {
231 part_end += psys->totchild;
232 }
233
234 if (part_end == 0) {
235 return mesh;
236 }
237
238 sim.depsgraph = ctx->depsgraph;
239 sim.scene = scene;
240 sim.ob = pimd->ob;
241 sim.psys = psys;
242 sim.psmd = psys_get_modifier(pimd->ob, psys);
243 between = (psys->part->childtype == PART_CHILD_FACES);
244
246 float *si;
247 si = size = MEM_new_array_zeroed<float>(part_end, __func__);
248
250 for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) {
251 *si = pa->size;
252 }
253 }
254
256 ChildParticle *cpa = psys->child;
257
258 for (p = 0; p < psys->totchild; p++, cpa++, si++) {
259 *si = psys_get_child_size(psys, cpa, 0.0f, nullptr);
260 }
261 }
262 }
263
264 switch (pimd->space) {
266 /* particle states are in world space already */
267 unit_m4(spacemat);
268 break;
270 /* get particle states in the particle object's local space */
271 invert_m4_m4(spacemat, pimd->ob->object_to_world().ptr());
272 break;
273 default:
274 /* should not happen */
275 BLI_assert(false);
276 break;
277 }
278
279 totvert = mesh->verts_num;
280 faces_num = mesh->faces_num;
281 totloop = mesh->corners_num;
282 totedge = mesh->edges_num;
283
284 /* count particles */
285 maxvert = 0;
286 maxpoly = 0;
287 maxloop = 0;
288 maxedge = 0;
289
290 for (p = part_start; p < part_end; p++) {
291 if (particle_skip(pimd, psys, p)) {
292 continue;
293 }
294
295 maxvert += totvert;
296 maxpoly += faces_num;
297 maxloop += totloop;
298 maxedge += totedge;
299 }
300
301 psys_sim_data_init(&sim);
302
303 if (psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) {
304 if (const std::optional<Bounds<float3>> bounds = mesh->bounds_min_max()) {
305 min_co = bounds->min[track];
306 max_co = bounds->max[track];
307 }
308 }
309
310 result = BKE_mesh_new_nomain_from_template(mesh, maxvert, maxedge, maxpoly, maxloop);
311
312 const OffsetIndices orig_faces = mesh->faces();
313 const Span<int> orig_corner_verts = mesh->corner_verts();
314 const Span<int> orig_corner_edges = mesh->corner_edges();
315 MutableSpan<float3> positions = result->vert_positions_for_write();
316 MutableSpan<int2> edges = result->edges_for_write();
317 MutableSpan<int> face_offsets = result->face_offsets_for_write();
318 MutableSpan<int> corner_verts = result->corner_verts_for_write();
319 MutableSpan<int> corner_edges = result->corner_edges_for_write();
320 bke::MutableAttributeAccessor attributes = result->attributes_for_write();
321 bke::SpanAttributeWriter mloopcols_index =
324 bke::SpanAttributeWriter mloopcols_value =
327
332
333 int *vert_part_index = nullptr;
334 float *vert_part_value = nullptr;
335 if (mloopcols_index) {
336 vert_part_index = MEM_new_array_zeroed<int>(maxvert, "vertex part index array");
337 }
338 if (mloopcols_value) {
339 vert_part_value = MEM_new_array_zeroed<float>(maxvert, "vertex part value array");
340 }
341
342 for (p = part_start, p_skip = 0; p < part_end; p++) {
343 float prev_dir[3];
344 float frame[4]; /* frame orientation quaternion */
345 float p_random = psys_frand(psys, 77091 + 283 * p);
346
347 /* skip particle? */
348 if (particle_skip(pimd, psys, p)) {
349 continue;
350 }
351
352 /* set vertices coordinates */
353
354 vert_interp.copy(0, p_skip * totvert, totvert);
355
356 for (k = 0; k < totvert; k++) {
358 int vindex = p_skip * totvert + k;
359
360 if (vert_part_index != nullptr) {
361 vert_part_index[vindex] = p;
362 }
363 if (vert_part_value != nullptr) {
364 vert_part_value[vindex] = p_random;
365 }
366
367 /* Change orientation based on object trackflag. */
368 copy_v3_v3(temp_co, positions[vindex]);
369 positions[vindex][axis] = temp_co[track];
370 positions[vindex][(axis + 1) % 3] = temp_co[(track + 1) % 3];
371 positions[vindex][(axis + 2) % 3] = temp_co[(track + 2) % 3];
372
373 /* get particle state */
374 if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) &&
376 {
377 float ran = 0.0f;
378 if (pimd->random_position != 0.0f) {
379 ran = pimd->random_position * BLI_hash_frand(psys->seed + p);
380 }
381
383 state.time = pimd->position * (1.0f - ran);
384 }
385 else {
386 state.time = (positions[vindex][axis] - min_co) / (max_co - min_co) * pimd->position *
387 (1.0f - ran);
388
389 if (trackneg) {
390 state.time = 1.0f - state.time;
391 }
392
393 positions[vindex][axis] = 0.0;
394 }
395
396 psys_get_particle_on_path(&sim, p, &state, true);
397
398 normalize_v3(state.vel);
399
400 /* Incrementally Rotating Frame (Bishop Frame) */
401 if (k == 0) {
402 float hairmat[4][4];
403 float mat[3][3];
404
405 if (p < psys->totpart) {
406 pa = psys->particles + p;
407 }
408 else {
409 ChildParticle *cpa = psys->child + (p - psys->totpart);
410 pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
411 }
412 psys_mat_hair_to_global(sim.ob, sim.psmd->mesh_final, sim.psys->part->from, pa, hairmat);
413 copy_m3_m4(mat, hairmat);
414 /* to quaternion */
415 mat3_to_quat(frame, mat);
416
417 if (pimd->rotation > 0.0f || pimd->random_rotation > 0.0f) {
418 float angle = 2.0f * M_PI *
419 (pimd->rotation +
420 pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
421 const float eul[3] = {0.0f, 0.0f, angle};
422 float rot[4];
423
424 eul_to_quat(rot, eul);
425 mul_qt_qtqt(frame, frame, rot);
426 }
427
428 /* NOTE: direction is same as normal vector currently,
429 * but best to keep this separate so the frame can be
430 * rotated later if necessary
431 */
432 copy_v3_v3(prev_dir, state.vel);
433 }
434 else {
435 float rot[4];
436
437 /* incrementally rotate along bend direction */
439 mul_qt_qtqt(frame, rot, frame);
440
441 copy_v3_v3(prev_dir, state.vel);
442 }
443
444 copy_qt_qt(state.rot, frame);
445#if 0
446 /* Absolute Frame (Frenet Frame) */
447 if (state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) {
448 unit_qt(state.rot);
449 }
450 else {
451 float cross[3];
452 float temp[3] = {0.0f, 0.0f, 0.0f};
453 temp[axis] = 1.0f;
454
455 cross_v3_v3v3(cross, temp, state.vel);
456
457 /* state.vel[axis] is the only component surviving from a dot product with the axis */
459 }
460#endif
461 }
462 else {
463 state.time = -1.0;
464 psys_get_particle_state(&sim, p, &state, true);
465 }
466
467 mul_qt_v3(state.rot, positions[vindex]);
469 mul_v3_fl(positions[vindex], size[p]);
470 }
471 add_v3_v3(positions[vindex], state.co);
472
473 mul_m4_v3(spacemat, positions[vindex]);
474 }
475
476 /* Create edges and adjust edge vertex indices. */
477 edge_interp.copy(0, p_skip * totedge, totedge);
478 int2 *edge = &edges[p_skip * totedge];
479 for (k = 0; k < totedge; k++, edge++) {
480 (*edge)[0] += p_skip * totvert;
481 (*edge)[1] += p_skip * totvert;
482 }
483
484 face_interp.copy(0, p_skip * faces_num, faces_num);
485 corner_interp.copy(0, p_skip * totloop, totloop);
486
487 /* create faces and loops */
488 for (k = 0; k < faces_num; k++) {
489 const IndexRange in_face = orig_faces[k];
490
491 const int dst_face_start = in_face.start() + p_skip * totloop;
492 face_offsets[p_skip * faces_num + k] = dst_face_start;
493
494 {
495 int orig_corner_i = in_face.start();
496 int dst_corner_i = dst_face_start;
497 int j = in_face.size();
498
499 for (; j; j--, orig_corner_i++, dst_corner_i++) {
500 corner_verts[dst_corner_i] = orig_corner_verts[orig_corner_i] + (p_skip * totvert);
501 corner_edges[dst_corner_i] = orig_corner_edges[orig_corner_i] + (p_skip * totedge);
502 const int vert = corner_verts[dst_corner_i];
503 if (mloopcols_index) {
504 const int part_index = vert_part_index[vert];
505 store_float_in_vcol(&mloopcols_index.span[dst_corner_i],
506 float(part_index) / float(psys->totpart - 1));
507 }
508 if (mloopcols_value) {
509 const float part_value = vert_part_value[vert];
510 store_float_in_vcol(&mloopcols_value.span[dst_corner_i], part_value);
511 }
512 }
513 }
514 }
515 p_skip++;
516 }
517
518 psys_sim_data_free(&sim);
519
520 if (size) {
521 MEM_delete(size);
522 }
523
524 MEM_SAFE_DELETE(vert_part_index);
525 MEM_SAFE_DELETE(vert_part_value);
526
527 mloopcols_index.finish();
528 mloopcols_value.finish();
529
530 return result;
531}
532
533static void panel_draw(const bContext * /*C*/, Panel *panel)
534{
535 ui::Layout &layout = *panel->layout;
537
538 PointerRNA ob_ptr;
540
541 PointerRNA particle_obj_ptr = RNA_pointer_get(ptr, "object");
542
543 layout.use_property_split_set(true);
544
545 layout.prop(ptr, "object", UI_ITEM_NONE, std::nullopt, ICON_NONE);
546 if (particle_obj_ptr) {
547 layout.prop_search(ptr,
548 "particle_system",
549 &particle_obj_ptr,
550 "particle_systems",
551 IFACE_("Particle System"),
552 ICON_NONE);
553 }
554 else {
555 layout.prop(ptr, "particle_system_index", UI_ITEM_NONE, IFACE_("Particle System"), ICON_NONE);
556 }
557
558 layout.separator();
559
560 ui::Layout *row = &layout.row(true, IFACE_("Create Instances"));
561 row->prop(ptr, "use_normal", toggles_flag, std::nullopt, ICON_NONE);
562 row->prop(ptr, "use_children", toggles_flag, std::nullopt, ICON_NONE);
563 row->prop(ptr, "use_size", toggles_flag, std::nullopt, ICON_NONE);
564
565 row = &layout.row(true, IFACE_("Show"));
566 row->prop(ptr, "show_alive", toggles_flag, std::nullopt, ICON_NONE);
567 row->prop(ptr, "show_dead", toggles_flag, std::nullopt, ICON_NONE);
568 row->prop(ptr, "show_unborn", toggles_flag, std::nullopt, ICON_NONE);
569
570 layout.prop(ptr,
571 "particle_amount",
574 ICON_NONE);
575 layout.prop(ptr, "particle_offset", UI_ITEM_NONE, IFACE_("Offset"), ICON_NONE);
576
577 layout.separator();
578
579 layout.prop(ptr, "space", UI_ITEM_NONE, IFACE_("Coordinate Space"), ICON_NONE);
580 row = &layout.row(true);
581 row->prop(ptr, "axis", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
582
583 modifier_error_message_draw(layout, ptr);
584}
585
586static void path_panel_draw_header(const bContext * /*C*/, Panel *panel)
587{
588 ui::Layout &layout = *panel->layout;
589
591
592 layout.prop(ptr, "use_path", UI_ITEM_NONE, IFACE_("Create Along Paths"), ICON_NONE);
593}
594
595static void path_panel_draw(const bContext * /*C*/, Panel *panel)
596{
597 ui::Layout &layout = *panel->layout;
598
599 PointerRNA ob_ptr;
601
602 layout.use_property_split_set(true);
603
604 layout.active_set(RNA_boolean_get(ptr, "use_path"));
605
606 ui::Layout *col = &layout.column(true);
607 col->prop(ptr, "position", ui::ITEM_R_SLIDER, std::nullopt, ICON_NONE);
608 col->prop(ptr, "random_position", ui::ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
609 col = &layout.column(true);
610 col->prop(ptr, "rotation", ui::ITEM_R_SLIDER, std::nullopt, ICON_NONE);
611 col->prop(ptr, "random_rotation", ui::ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
612
613 layout.prop(ptr, "use_preserve_shape", UI_ITEM_NONE, std::nullopt, ICON_NONE);
614}
615
616static void layers_panel_draw(const bContext * /*C*/, Panel *panel)
617{
618 ui::Layout &layout = *panel->layout;
619
620 PointerRNA ob_ptr;
622
623 PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
624
625 layout.use_property_split_set(true);
626
627 ui::Layout &col = layout.column(false);
628 col.prop_search(
629 ptr, "index_layer_name", &obj_data_ptr, "vertex_colors", IFACE_("Index"), ICON_NONE);
630 col.prop_search(
631 ptr, "value_layer_name", &obj_data_ptr, "vertex_colors", IFACE_("Value"), ICON_NONE);
632}
633
634static void panel_register(ARegionType *region_type)
635{
639 region_type, "paths", "", path_panel_draw_header, path_panel_draw, panel_type);
641 region_type, "layers", "Layers", nullptr, layers_panel_draw, panel_type);
642}
643
645 /*idname*/ "ParticleInstance",
646 /*name*/ N_("ParticleInstance"),
647 /*struct_name*/ "ParticleInstanceModifierData",
648 /*struct_size*/ sizeof(ParticleInstanceModifierData),
649 /*srna*/ &RNA_ParticleInstanceModifier,
653 /*icon*/ ICON_MOD_PARTICLE_INSTANCE,
654
655 /*copy_data*/ BKE_modifier_copydata_generic,
656
657 /*deform_verts*/ nullptr,
658 /*deform_matrices*/ nullptr,
659 /*deform_verts_EM*/ nullptr,
660 /*deform_matrices_EM*/ nullptr,
661 /*modify_mesh*/ modify_mesh,
662 /*modify_geometry_set*/ nullptr,
663
664 /*init_data*/ init_data,
665 /*required_data_mask*/ required_data_mask,
666 /*free_data*/ nullptr,
667 /*is_disabled*/ is_disabled,
668 /*update_depsgraph*/ update_depsgraph,
669 /*depends_on_time*/ nullptr,
670 /*depends_on_normals*/ nullptr,
671 /*foreach_ID_link*/ foreach_ID_link,
672 /*foreach_tex_link*/ nullptr,
673 /*free_runtime_data*/ nullptr,
674 /*panel_register*/ panel_register,
675 /*blend_write*/ nullptr,
676 /*blend_read*/ nullptr,
677 /*foreach_cache*/ nullptr,
678 /*foreach_working_space_color*/ nullptr,
679};
680
681} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
#define M_PI
Random number functions.
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_COUNTABLE
Read Blender memory allocation and freeing.
#define UI_ITEM_NONE
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define CD_MASK_PROP_BYTE_COLOR
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
ChannelStorageType r
ChannelStorageType g
ChannelStorageType b
ChannelStorageType a
constexpr int64_t size() const
constexpr int64_t start() const
void copy(int src_index, int dst_index, int count) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
#define rot(x, k)
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
const int state
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void path_panel_draw_header(const bContext *, Panel *panel)
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void psys_sim_data_init(struct ParticleSimulationData *sim)
Definition particle.cc:621
float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT
Definition rand.cc:150
static void layers_panel_draw(const bContext *, Panel *panel)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
@ eModifierType_ParticleSystem
@ eModifierType_ParticleInstance
MINLINE float safe_acosf(float a)
static void init_data(ModifierData *md)
void(*)(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag) IDWalkFunc
static void update_depsgraph(tGraphSliderOp *gso)
static void store_float_in_vcol(ColorGeometry4b *vcol, float float_value)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
Definition particle.cc:2190
MINLINE void mul_v3_fl(float r[3], float f)
static void required_data_mask(ModifierData *, CustomData_MeshMasks *r_cddata_masks)
void mul_qt_v3(const float q[4], float r[3])
void psys_get_particle_on_path(struct ParticleSimulationData *sim, int pa_num, struct ParticleKey *state, bool vel)
Definition particle.cc:4643
void mul_m4_v3(const float M[4][4], float r[3])
void unit_qt(float q[4])
void modifier_error_message_draw(ui::Layout &layout, PointerRNA *ptr)
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time)
Definition particle.cc:4554
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
VecBase< int32_t, 2 > int2
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
Definition particle.cc:4930
unsigned char uchar
Definition BKE_text.h:58
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_qt_qt(float q[4], const float a[4])
static void panel_register(ARegionType *region_type)
void eul_to_quat(float quat[4], const float eul[3])
static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psys, int p)
void unit_m4(float m[4][4])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
Definition MOD_array.cc:873
@ eModifierTypeFlag_SupportsMapping
@ eModifierTypeFlag_EnableInEditmode
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
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
static void path_panel_draw(const bContext *, Panel *panel)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
static void panel_draw(const bContext *, Panel *panel)
PanelType * modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
ModifierTypeInfo modifierType_ParticleInstance
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
static bool is_disabled(const Scene *, ModifierData *md, bool)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
void mat3_to_quat(float q[4], const float mat[3][3])
void psys_sim_data_free(struct ParticleSimulationData *sim)
Definition particle.cc:662
@ eParticleInstanceFlag_Parents
@ eParticleInstanceFlag_Children
@ eParticleInstanceFlag_KeepShape
@ eParticleInstanceFlag_UseSize
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
ListBaseT< ModifierData > modifiers
ListBaseT< struct ParticleSystem > particlesystem
eObject_Axis trackflag
ui::Layout * layout
eParticle_AliveState alive
ParticleInstanceModifierSpace space
struct ParticleSystem * psys
struct ParticleSystemModifierData * psmd
eParticleSystem_Flag flag
struct PointCache * pointcache
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< StringRefNull > name, int icon, bool results_are_suggestions)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
#define N_(msgid)