43 #include "RNA_prototypes.h"
58 static float I[4][4] = {
59 {1.0f, 0.0f, 0.0f, 0.0f},
60 {0.0f, 1.0f, 0.0f, 0.0f},
61 {0.0f, 0.0f, 1.0f, 0.0f},
62 {0.0f, 0.0f, 0.0f, 1.0f},
88 ot->
name =
"Add Particle System Slot";
89 ot->
idname =
"OBJECT_OT_particle_system_add";
112 mode_orig = ob->
mode;
136 ot->
name =
"Remove Particle System Slot";
137 ot->
idname =
"OBJECT_OT_particle_system_remove";
197 ot->
name =
"New Particle Settings";
225 for (; pt; pt = pt->next) {
247 ot->
name =
"New Particle Target";
248 ot->
idname =
"PARTICLE_OT_new_target";
272 for (; pt; pt = pt->next) {
296 ot->
name =
"Remove Particle Target";
297 ot->
idname =
"PARTICLE_OT_target_remove";
321 for (; pt; pt = pt->next) {
337 ot->
name =
"Move Up Target";
338 ot->
idname =
"PARTICLE_OT_target_move_up";
360 for (; pt; pt = pt->next) {
376 ot->
name =
"Move Down Target";
377 ot->
idname =
"PARTICLE_OT_target_move_down";
406 ot->
name =
"Refresh Instance Objects";
407 ot->
idname =
"PARTICLE_OT_dupliob_refresh";
408 ot->
description =
"Refresh list of instance objects and their weights";
446 ot->
name =
"Move Up Instance Object";
447 ot->
idname =
"PARTICLE_OT_dupliob_move_up";
488 ot->
name =
"Copy Particle Instance Object";
489 ot->
idname =
"PARTICLE_OT_dupliob_copy";
533 ot->
name =
"Remove Particle Instance Object";
534 ot->
idname =
"PARTICLE_OT_dupliob_remove";
574 ot->
name =
"Move Down Instance Object";
575 ot->
idname =
"PARTICLE_OT_dupliob_move_down";
611 for (i = 0, pa = psys->
particles; i < psys->totpart; i++, pa++) {
619 for (k = 0, key = pa->
hair; k < pa->totkey; k++, key++) {
670 ot->
name =
"Disconnect Hair";
672 ot->
idname =
"PARTICLE_OT_disconnect_hair";
681 ot->
srna,
"all", 0,
"All Hair",
"Disconnect all hair systems from the emitter mesh");
694 const float from_mat[4][4],
695 const float to_mat[4][4],
712 float from_ob_imat[4][4], to_ob_imat[4][4];
713 float from_imat[4][4], to_imat[4][4];
725 edit_point = target_edit ? target_edit->
points :
NULL;
756 for (
int i = 0; i < numverts; i++) {
774 for (i = 0, tpa = target_psys->
particles, pa = psys->
particles; i < target_psys->totpart;
792 if (nearest.
index == -1) {
794 printf(
"No nearest point found for hair root!");
802 mf = &mface[nearest.
index];
817 if (use_dm_final_indices) {
826 me = &medge[nearest.
index];
829 tpa->
fuv[0] = 1.0f - tpa->
fuv[1];
830 tpa->
fuv[2] = tpa->
fuv[3] = 0.0f;
840 float hairmat[4][4], imat[4][4];
858 for (k = 0, key = pa->
hair, tkey = tpa->
hair, ekey = edit_point->
keys; k < tpa->totkey;
859 k++, key++, tkey++, ekey++) {
880 for (k = 0, key = pa->
hair, tkey = tpa->
hair; k < tpa->totkey; k++, key++, tkey++) {
942 bool any_connected =
false;
958 if (!any_connected) {
961 "No hair connected (can't connect hair if particle system modifier is disabled)");
973 ot->
name =
"Connect Hair";
975 ot->
idname =
"PARTICLE_OT_connect_hair";
1015 edit->emitter_field =
NULL;
1016 edit->emitter_cosnos =
NULL;
1026 key->time = &hkey->
time;
1081 bool duplicate_settings)
1108 #define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first)
1109 #define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next)
1118 if (psys_start ==
NULL) {
1127 psys_start = totpsys > 0 ? tmp_psys[0] :
NULL;
1151 if (psys_from->edit) {
1155 if (duplicate_settings) {
1167 float(*from_mat)[4], (*to_mat)[4];
1175 from_mat = ob_from->
obmat;
1176 to_mat = ob_to->
obmat;
1180 from_mat = to_mat =
NULL;
1184 if (ob_from != ob_to) {
1202 #undef PSYS_FROM_FIRST
1203 #undef PSYS_FROM_NEXT
1205 if (duplicate_settings) {
1231 const bool remove_target_particles =
RNA_boolean_get(op->
ptr,
"remove_target_particles");
1239 if (psys_from ==
NULL) {
1245 int changed_tot = 0;
1249 if (ob_from != ob_to) {
1250 bool changed =
false;
1251 if (remove_target_particles) {
1269 if (changed_tot > 0) {
1274 if ((changed_tot == 0 && fail == 0) || fail) {
1277 "Copy particle systems to selected: %d done, %d failed",
1293 ot->
name =
"Copy Particle Systems";
1294 ot->
description =
"Copy particle systems from the active object to selected objects";
1295 ot->
idname =
"PARTICLE_OT_copy_particle_systems";
1308 "Space transform for copying from one object to another");
1310 "remove_target_particles",
1312 "Remove Target Particles",
1313 "Remove particle systems on the target objects");
1318 "Use the active particle system from the context");
1351 ot->
name =
"Duplicate Particle System";
1352 ot->
description =
"Duplicate particle system within the active object";
1353 ot->
idname =
"PARTICLE_OT_duplicate_particle_system";
1362 "use_duplicate_settings",
1364 "Duplicate Settings",
1365 "Duplicate settings as well, so the new particle system uses its own settings");
typedef float(TangentPoint)[2]
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, const struct Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
struct Scene * CTX_data_scene(const bContext *C)
#define CTX_DATA_BEGIN(C, Type, instance, member)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
bool BKE_id_is_editable(const struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
void BKE_id_free(struct Main *bmain, void *idv)
void BKE_mesh_tessface_ensure(struct Mesh *mesh)
void BKE_modifier_free(struct ModifierData *md)
struct ModifierData * BKE_modifier_new(int type)
bool BKE_modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md)
General operations, lookup, etc. for blender objects.
void BKE_object_free_particlesystems(struct Object *ob)
struct ParticleSystem * BKE_object_copy_particlesystem(struct ParticleSystem *psys, int flag)
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
struct ParticleSettings * BKE_particlesettings_add(struct Main *bmain, const char *name)
void psys_check_group_weights(struct ParticleSettings *part)
void psys_mat_hair_to_object(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname)
void psys_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
struct ParticleSystem * psys_get_current(struct Object *ob)
void psys_check_boid_data(struct ParticleSystem *psys)
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit)
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)
struct ModifierData * object_add_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
void interp_weights_poly_v3(float w[], float v[][3], int n, const float co[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
bool invert_m4_m4(float R[4][4], const float A[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_graph_tag_relations_update(struct Depsgraph *graph)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
#define ID_IS_LINKED(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ eModifierType_ParticleSystem
@ eModifierType_DynamicPaint
#define PART_DUPLIW_CURRENT
struct Object * ED_object_context(const struct bContext *C)
struct Object * ED_object_active_context(const struct bContext *C)
struct ParticleEditSettings * PE_settings(struct Scene *scene)
void PE_update_object(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, int useflag)
bool ED_operator_object_active_local_editable(struct bContext *C)
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
__forceinline bool all(const avxb &b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), ParticleSystem *psys)
void update_world_cos(Object *ob, PTCacheEdit *edit)
void recalc_lengths(PTCacheEdit *edit)
static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
static int connect_hair_exec(bContext *C, wmOperator *op)
static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
static bool duplicate_particle_systems_poll(bContext *C)
static int copy_particle_systems_exec(bContext *C, wmOperator *op)
void PARTICLE_OT_target_move_up(wmOperatorType *ot)
void PARTICLE_OT_dupliob_copy(wmOperatorType *ot)
void PARTICLE_OT_dupliob_refresh(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)
static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
void PARTICLE_OT_new(wmOperatorType *ot)
void PARTICLE_OT_new_target(wmOperatorType *ot)
static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
static bool psys_poll(bContext *C)
static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
void PARTICLE_OT_target_remove(wmOperatorType *ot)
static void copy_particle_edit(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
static bool copy_particle_systems_poll(bContext *C)
void PARTICLE_OT_connect_hair(wmOperatorType *ot)
void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot)
void PARTICLE_OT_dupliob_remove(wmOperatorType *ot)
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)
static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
static void remove_particle_systems_from_object(Object *ob_to)
static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int disconnect_hair_exec(bContext *C, wmOperator *op)
static int duplicate_particle_systems_exec(bContext *C, wmOperator *op)
static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot)
#define PSYS_FROM_NEXT(cur)
static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_particle_system_add(wmOperatorType *ot)
void PARTICLE_OT_target_move_down(wmOperatorType *ot)
void PARTICLE_OT_duplicate_particle_system(wmOperatorType *ot)
static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
static const EnumPropertyItem space_items[]
BVHTree_NearestPointCallback nearest_callback
struct ModifierData * next
struct PTCacheEditKey * keys
struct ParticleCacheKey ** pathcache
PTCacheEditPoint * points
struct ParticleDupliWeight * prev
struct ParticleDupliWeight * next
struct ListBase instance_weights
struct ParticleSystem * psys
struct Mesh * mesh_original
struct PTCacheEdit * edit
struct ParticleSystem * next
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)