72 static float I[4][4] = {
73 {1.0f, 0.0f, 0.0f, 0.0f},
74 {0.0f, 1.0f, 0.0f, 0.0f},
75 {0.0f, 0.0f, 1.0f, 0.0f},
76 {0.0f, 0.0f, 0.0f, 1.0f},
102 ot->
name =
"Add Particle System Slot";
103 ot->
idname =
"OBJECT_OT_particle_system_add";
126 mode_orig = ob->
mode;
149 ot->
name =
"Remove Particle System Slot";
150 ot->
idname =
"OBJECT_OT_particle_system_remove";
210 ot->
name =
"New Particle Settings";
238 for (; pt; pt = pt->next) {
260 ot->
name =
"New Particle Target";
261 ot->
idname =
"PARTICLE_OT_new_target";
285 for (; pt; pt = pt->next) {
309 ot->
name =
"Remove Particle Target";
310 ot->
idname =
"PARTICLE_OT_target_remove";
334 for (; pt; pt = pt->next) {
350 ot->
name =
"Move Up Target";
351 ot->
idname =
"PARTICLE_OT_target_move_up";
373 for (; pt; pt = pt->next) {
389 ot->
name =
"Move Down Target";
390 ot->
idname =
"PARTICLE_OT_target_move_down";
419 ot->
name =
"Refresh Instance Objects";
420 ot->
idname =
"PARTICLE_OT_dupliob_refresh";
421 ot->
description =
"Refresh list of instance objects and their weights";
459 ot->
name =
"Move Up Instance Object";
460 ot->
idname =
"PARTICLE_OT_dupliob_move_up";
501 ot->
name =
"Copy Particle Instance Object";
502 ot->
idname =
"PARTICLE_OT_dupliob_copy";
546 ot->
name =
"Remove Particle Instance Object";
547 ot->
idname =
"PARTICLE_OT_dupliob_remove";
587 ot->
name =
"Move Down Instance Object";
588 ot->
idname =
"PARTICLE_OT_dupliob_move_down";
624 for (i = 0, pa = psys->
particles; i < psys->totpart; i++, pa++) {
632 for (k = 0, key = pa->
hair; k < pa->totkey; k++, key++) {
683 ot->
name =
"Disconnect Hair";
685 ot->
idname =
"PARTICLE_OT_disconnect_hair";
694 ot->
srna,
"all", 0,
"All Hair",
"Disconnect all hair systems from the emitter mesh");
707 const float from_mat[4][4],
708 const float to_mat[4][4],
725 float from_ob_imat[4][4], to_ob_imat[4][4];
726 float from_imat[4][4], to_imat[4][4];
738 edit_point = target_edit ? target_edit->
points :
NULL;
769 for (
int i = 0; i < numverts; i++) {
787 for (i = 0, tpa = target_psys->
particles, pa = psys->
particles; i < target_psys->totpart;
805 if (nearest.
index == -1) {
807 printf(
"No nearest point found for hair root!");
815 mf = &mface[nearest.
index];
830 if (use_dm_final_indices) {
839 me = &medge[nearest.
index];
842 tpa->
fuv[0] = 1.0f - tpa->
fuv[1];
843 tpa->
fuv[2] = tpa->
fuv[3] = 0.0f;
853 float hairmat[4][4], imat[4][4];
870 for (k = 0, key = pa->
hair, tkey = tpa->
hair, ekey = edit_point->
keys; k < tpa->totkey;
871 k++, key++, tkey++, ekey++) {
892 for (k = 0, key = pa->
hair, tkey = tpa->
hair; k < tpa->totkey; k++, key++, tkey++) {
954 bool any_connected =
false;
970 if (!any_connected) {
973 "No hair connected (can't connect hair if particle system modifier is disabled)");
985 ot->
name =
"Connect Hair";
987 ot->
idname =
"PARTICLE_OT_connect_hair";
1027 edit->emitter_field =
NULL;
1028 edit->emitter_cosnos =
NULL;
1038 key->time = &hkey->
time;
1093 bool duplicate_settings)
1120 #define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first)
1121 #define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next)
1130 if (psys_start ==
NULL) {
1139 psys_start = totpsys > 0 ? tmp_psys[0] :
NULL;
1163 if (psys_from->edit) {
1167 if (duplicate_settings) {
1179 float(*from_mat)[4], (*to_mat)[4];
1187 from_mat = ob_from->
obmat;
1188 to_mat = ob_to->
obmat;
1192 from_mat = to_mat =
NULL;
1196 if (ob_from != ob_to) {
1214 #undef PSYS_FROM_FIRST
1215 #undef PSYS_FROM_NEXT
1217 if (duplicate_settings) {
1243 const bool remove_target_particles =
RNA_boolean_get(op->
ptr,
"remove_target_particles");
1251 int changed_tot = 0;
1255 if (ob_from != ob_to) {
1256 bool changed =
false;
1257 if (remove_target_particles) {
1275 if (changed_tot > 0) {
1280 if ((changed_tot == 0 && fail == 0) || fail) {
1283 "Copy particle systems to selected: %d done, %d failed",
1299 ot->
name =
"Copy Particle Systems";
1300 ot->
description =
"Copy particle systems from the active object to selected objects";
1301 ot->
idname =
"PARTICLE_OT_copy_particle_systems";
1314 "Space transform for copying from one object to another");
1316 "remove_target_particles",
1318 "Remove Target Particles",
1319 "Remove particle systems on the target objects");
1324 "Use the active particle system from the context");
1357 ot->
name =
"Duplicate Particle System";
1358 ot->
description =
"Duplicate particle system within the active object";
1359 ot->
idname =
"PARTICLE_OT_duplicate_particle_system";
1368 "use_duplicate_settings",
1370 "Duplicate Settings",
1371 "Duplicate settings as well, so the new particle system uses its own settings");
typedef float(TangentPoint)[2]
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, struct Mesh *mesh, const BVHCacheType bvh_cache_type, const int tree_type)
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
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)
void id_us_min(struct ID *id)
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag)
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.
struct ParticleSystem * BKE_object_copy_particlesystem(struct ParticleSystem *psys, const int flag)
void BKE_object_free_particlesystems(struct Object *ob)
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 object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob)
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname)
int psys_particle_dm_face_lookup(struct Mesh *mesh_final, struct Mesh *mesh_original, int findex, const float fw[4], struct LinkNode **poly_nodes)
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)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit)
struct ModifierData * object_add_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name)
void BKE_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
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)
void interp_weights_poly_v3(float w[], float v[][3], const int n, const float co[3])
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[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)
@ 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.
StructRNA RNA_ParticleSystem
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
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
__forceinline bool all(const avxb &b)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)