37#include "RNA_prototypes.hh"
77 if (psys ==
nullptr) {
87 if (psmd->
psys == psys) {
90 if (use_render_params) {
112 if (pimd->
ob !=
nullptr) {
131 int totpart, randp, minp, maxp;
172 return randp < minp || randp >= maxp;
175 return randp < minp && randp >= maxp;
184 vcol->
r = vcol->
g = vcol->
b = value;
196 int totvert, faces_num, totloop, totedge;
197 int maxvert, maxpoly, maxloop, maxedge, part_end = 0, part_start;
200 float max_co = 0.0, min_co = 0.0, temp_co[3];
201 float *size =
nullptr;
202 float spacemat[4][4];
216 if (psys ==
nullptr || psys->
totpart == 0) {
224 part_start = use_parents ? 0 : psys->
totpart;
247 si = size =
static_cast<float *
>(
MEM_calloc_arrayN(part_end,
sizeof(
float), __func__));
258 for (p = 0; p < psys->
totchild; p++, cpa++, si++) {
264 switch (pimd->
space) {
279 totvert = mesh->verts_num;
280 faces_num = mesh->faces_num;
281 totloop = mesh->corners_num;
282 totedge = mesh->edges_num;
290 for (p = part_start; p < part_end; p++) {
296 maxpoly += faces_num;
305 min_co =
bounds->min[track];
306 max_co =
bounds->max[track];
325 int *vert_part_index =
nullptr;
326 float *vert_part_value =
nullptr;
327 if (mloopcols_index !=
nullptr) {
328 vert_part_index = MEM_cnew_array<int>(maxvert,
"vertex part index array");
330 if (mloopcols_value) {
331 vert_part_value = MEM_cnew_array<float>(maxvert,
"vertex part value array");
334 for (p = part_start, p_skip = 0; p < part_end; p++) {
337 float p_random =
psys_frand(psys, 77091 + 283 * p);
345 for (k = 0; k < totvert; k++) {
347 int vindex = p_skip * totvert + k;
351 if (vert_part_index !=
nullptr) {
352 vert_part_index[vindex] = p;
354 if (vert_part_value !=
nullptr) {
355 vert_part_value[vindex] = p_random;
360 positions[vindex][axis] = temp_co[track];
361 positions[vindex][(axis + 1) % 3] = temp_co[(track + 1) % 3];
362 positions[vindex][(axis + 2) % 3] = temp_co[(track + 2) % 3];
377 state.time = (positions[vindex][axis] - min_co) / (max_co - min_co) * pimd->
position *
384 positions[vindex][axis] = 0.0;
396 if (p < psys->totpart) {
409 float angle = 2.0f *
M_PI *
412 const float eul[3] = {0.0f, 0.0f, angle};
438 if (
state.vel[axis] < -0.9999f ||
state.vel[axis] > 0.9999f) {
443 float temp[3] = {0.0f, 0.0f, 0.0f};
470 for (k = 0; k < totedge; k++, edge++) {
471 (*edge)[0] += p_skip * totvert;
472 (*edge)[1] += p_skip * totvert;
476 for (k = 0; k < faces_num; k++) {
480 const int dst_face_start = in_face.
start() + p_skip * totloop;
481 face_offsets[p_skip * faces_num + k] = dst_face_start;
484 int orig_corner_i = in_face.
start();
485 int dst_corner_i = dst_face_start;
486 int j = in_face.
size();
489 &mesh->corner_data, &result->corner_data, in_face.
start(), dst_face_start, j);
490 for (; j; j--, orig_corner_i++, dst_corner_i++) {
491 corner_verts[dst_corner_i] = orig_corner_verts[orig_corner_i] + (p_skip * totvert);
492 corner_edges[dst_corner_i] = orig_corner_edges[orig_corner_i] + (p_skip * totedge);
493 const int vert = corner_verts[dst_corner_i];
494 if (mloopcols_index !=
nullptr) {
495 const int part_index = vert_part_index[vert];
497 float(part_index) /
float(psys->
totpart - 1));
499 if (mloopcols_value !=
nullptr) {
500 const float part_value = vert_part_value[vert];
541 IFACE_(
"Particle System"),
552 uiItemR(row,
ptr,
"use_normal", toggles_flag,
nullptr, ICON_NONE);
553 uiItemR(row,
ptr,
"use_children", toggles_flag,
nullptr, ICON_NONE);
554 uiItemR(row,
ptr,
"use_size", toggles_flag,
nullptr, ICON_NONE);
557 uiItemR(row,
ptr,
"show_alive", toggles_flag,
nullptr, ICON_NONE);
558 uiItemR(row,
ptr,
"show_dead", toggles_flag,
nullptr, ICON_NONE);
559 uiItemR(row,
ptr,
"show_unborn", toggles_flag,
nullptr, ICON_NONE);
618 col,
ptr,
"index_layer_name", &obj_data_ptr,
"vertex_colors",
IFACE_(
"Index"), ICON_NONE);
620 col,
ptr,
"value_layer_name", &obj_data_ptr,
"vertex_colors",
IFACE_(
"Value"), ICON_NONE);
635 N_(
"ParticleInstance"),
636 "ParticleInstanceModifierData",
638 &RNA_ParticleInstanceModifier,
642 ICON_MOD_PARTICLE_INSTANCE,
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, blender::StringRef name, int totelem)
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
@ eModifierTypeFlag_SupportsMapping
@ eModifierTypeFlag_EnableInEditmode
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
void(*)(void *user_data, Object *ob, ID **idpoin, int cb_flag) IDWalkFunc
void psys_get_particle_on_path(struct ParticleSimulationData *sim, int pa_num, struct ParticleKey *state, bool vel)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void psys_sim_data_free(struct ParticleSimulationData *sim)
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time)
void psys_sim_data_init(struct ParticleSimulationData *sim)
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float safe_acosf(float a)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void unit_m4(float m[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
void mat3_to_quat(float q[4], const float mat[3][3])
void mul_qt_v3(const float q[4], float r[3])
void eul_to_quat(float quat[4], const float eul[3])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void copy_qt_qt(float q[4], const float a[4])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
#define CD_MASK_PROP_BYTE_COLOR
#define DNA_struct_default_get(struct_name)
@ eParticleInstanceFlag_Parents
@ eParticleInstanceFlag_Alive
@ eParticleInstanceFlag_Dead
@ eParticleInstanceFlag_Children
@ eParticleInstanceFlag_Unborn
@ eParticleInstanceFlag_Path
@ eParticleInstanceFlag_UseSize
@ eParticleInstanceFlag_KeepShape
struct ParticleInstanceModifierData ParticleInstanceModifierData
@ eModifierType_ParticleSystem
@ eModifierType_ParticleInstance
@ eParticleInstanceSpace_World
@ eParticleInstanceSpace_Local
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
ModifierTypeInfo modifierType_ParticleInstance
static void panel_register(ARegionType *region_type)
static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psys, int p)
static void store_float_in_vcol(MLoopCol *vcol, float float_value)
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
static void path_panel_draw_header(const bContext *, Panel *panel)
static void layers_panel_draw(const bContext *, Panel *panel)
static void panel_draw(const bContext *, Panel *panel)
static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
static void path_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)
void modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void uiLayoutSetActive(uiLayout *layout, bool active)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
uiLayout * uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *heading)
void uiItemPointerR(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_FORCE_BLANK_DECORATE
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
constexpr int64_t size() const
constexpr int64_t start() const
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
#define unit_float_to_uchar_clamp(val)
ccl_device_inline float cross(const float2 a, const float2 b)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
bool RNA_pointer_is_null(const PointerRNA *ptr)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
char index_layer_name[68]
char value_layer_name[68]
struct Depsgraph * depsgraph
struct ParticleSystemModifierData * psmd
struct ParticleSystem * psys
struct ParticleSystem * psys
struct PointCache * pointcache