46#include "RNA_prototypes.hh"
59static float I[4][4] = {
60 {1.0f, 0.0f, 0.0f, 0.0f},
61 {0.0f, 1.0f, 0.0f, 0.0f},
62 {0.0f, 0.0f, 1.0f, 0.0f},
63 {0.0f, 0.0f, 0.0f, 1.0f},
89 ot->
name =
"Add Particle System Slot";
90 ot->
idname =
"OBJECT_OT_particle_system_add";
113 mode_orig = ob->
mode;
138 ot->
name =
"Remove Particle System Slot";
139 ot->
idname =
"OBJECT_OT_particle_system_remove";
200 ot->
name =
"New Particle Settings";
228 for (; pt; pt = pt->
next) {
229 pt->
flag &= ~PTARGET_CURRENT;
250 ot->
name =
"New Particle Target";
251 ot->
idname =
"PARTICLE_OT_new_target";
275 for (; pt; pt = pt->
next) {
299 ot->
name =
"Remove Particle Target";
300 ot->
idname =
"PARTICLE_OT_target_remove";
324 for (; pt; pt = pt->
next) {
340 ot->
name =
"Move Up Target";
341 ot->
idname =
"PARTICLE_OT_target_move_up";
363 for (; pt; pt = pt->
next) {
379 ot->
name =
"Move Down Target";
380 ot->
idname =
"PARTICLE_OT_target_move_down";
409 ot->
name =
"Refresh Instance Objects";
410 ot->
idname =
"PARTICLE_OT_dupliob_refresh";
411 ot->
description =
"Refresh list of instance objects and their weights";
448 ot->
name =
"Move Up Instance Object";
449 ot->
idname =
"PARTICLE_OT_dupliob_move_up";
472 dw->
flag &= ~PART_DUPLIW_CURRENT;
489 ot->
name =
"Copy Particle Instance Object";
490 ot->
idname =
"PARTICLE_OT_dupliob_copy";
533 ot->
name =
"Remove Particle Instance Object";
534 ot->
idname =
"PARTICLE_OT_dupliob_remove";
573 ot->
name =
"Move Down Instance Object";
574 ot->
idname =
"PARTICLE_OT_dupliob_move_down";
608 point = edit ? edit->
points :
nullptr;
618 for (k = 0, key = pa->
hair; k < pa->
totkey; k++, key++) {
622 ekey->
flag &= ~PEK_USE_WCO;
669 ot->
name =
"Disconnect Hair";
671 ot->
idname =
"PARTICLE_OT_disconnect_hair";
680 ot->
srna,
"all",
false,
"All Hair",
"Disconnect all hair systems from the emitter mesh");
693 const float from_mat[4][4],
694 const float to_mat[4][4],
705 const MFace *mface =
nullptr, *mf;
710 float from_ob_imat[4][4], to_ob_imat[4][4];
711 float from_imat[4][4], to_imat[4][4];
723 edit_point = target_edit ? target_edit->
points :
nullptr;
725 invert_m4_m4(from_ob_imat, ob->object_to_world().ptr());
726 invert_m4_m4(to_ob_imat, target_ob->object_to_world().ptr());
740 if (mesh ==
nullptr) {
750 numverts = mesh->verts_num;
754 for (
int i = 0; i < numverts; i++) {
758 if (mesh->totface_legacy != 0) {
762 else if (mesh->edges_num != 0) {
792 if (nearest.index == -1) {
794 printf(
"No nearest point found for hair root!");
802 mf = &mface[nearest.index];
816 tpa->
num = nearest.index;
817 if (use_dm_final_indices) {
826 edge = &edges[nearest.index];
829 tpa->
fuv[0] = 1.0f - tpa->
fuv[1];
830 tpa->
fuv[2] = tpa->
fuv[3] = 0.0f;
833 tpa->
num = nearest.index;
840 float hairmat[4][4], imat[4][4];
844 copy_m4_m4(imat, target_ob->object_to_world().ptr());
858 for (k = 0, key = pa->
hair, tkey = tpa->
hair, ekey = edit_point->
keys; k < tpa->
totkey;
859 k++, key++, tkey++, ekey++)
881 for (k = 0, key = pa->
hair, tkey = tpa->
hair; k < tpa->
totkey; k++, key++, tkey++) {
925 ob->object_to_world().ptr(),
926 ob->object_to_world().ptr(),
930 psys->
flag &= ~PSYS_GLOBAL_HAIR;
943 bool any_connected =
false;
959 if (!any_connected) {
962 "No hair connected (can't connect hair if particle system modifier is disabled)");
974 ot->
name =
"Connect Hair";
976 ot->
idname =
"PARTICLE_OT_connect_hair";
985 ot->
srna,
"all",
false,
"All Hair",
"Connect all hair systems to the emitter mesh");
1015 edit->mirror_cache =
nullptr;
1018 edit->emitter_field =
nullptr;
1019 edit->emitter_cosnos =
nullptr;
1029 key->time = &hkey->
time;
1085 bool duplicate_settings)
1112#define PSYS_FROM_FIRST \
1113 static_cast<ParticleSystem *>( \
1114 (single_psys_from ? single_psys_from : ob_from->particlesystem.first))
1115#define PSYS_FROM_NEXT(cur) (single_psys_from ? nullptr : (cur)->next)
1125 if (psys_start ==
nullptr) {
1134 psys_start = totpsys > 0 ? tmp_psys[0] :
nullptr;
1159 if (psys_from->edit) {
1163 if (duplicate_settings) {
1176 const float(*from_mat)[4], (*to_mat)[4];
1184 from_mat = ob_from->object_to_world().ptr();
1185 to_mat = ob_to->object_to_world().ptr();
1189 from_mat = to_mat =
nullptr;
1193 if (ob_from != ob_to) {
1211#undef PSYS_FROM_FIRST
1212#undef PSYS_FROM_NEXT
1238 const bool remove_target_particles =
RNA_boolean_get(op->
ptr,
"remove_target_particles");
1247 if (psys_from ==
nullptr) {
1253 int changed_tot = 0;
1257 if (ob_from != ob_to) {
1258 bool changed =
false;
1259 if (remove_target_particles) {
1277 if (changed_tot > 0) {
1281 if ((changed_tot == 0 && fail == 0) || fail) {
1284 "Copy particle systems to selected: %d done, %d failed",
1297 {0,
nullptr, 0,
nullptr,
nullptr},
1300 ot->
name =
"Copy Particle Systems";
1301 ot->
description =
"Copy particle systems from the active object to selected objects";
1302 ot->
idname =
"PARTICLE_OT_copy_particle_systems";
1315 "Space transform for copying from one object to another");
1317 "remove_target_particles",
1319 "Remove Target Particles",
1320 "Remove particle systems on the target objects");
1325 "Use the active particle system from the context");
1352 if (psys ==
nullptr) {
1363 ot->
name =
"Duplicate Particle System";
1364 ot->
description =
"Duplicate particle system within the active object";
1365 ot->
idname =
"PARTICLE_OT_duplicate_particle_system";
1374 "use_duplicate_settings",
1376 "Duplicate Settings",
1377 "Duplicate settings as well, so the new particle system uses its own settings");
void free_bvhtree_from_mesh(BVHTreeFromMesh *data)
BVHTree * BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, const Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
#define CTX_DATA_BEGIN(C, Type, instance, member)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
void BKE_id_free(Main *bmain, void *idv)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
ID * BKE_id_copy(Main *bmain, const ID *id)
void BKE_mesh_tessface_ensure(Mesh *mesh)
void BKE_modifiers_persistent_uid_init(const Object &object, ModifierData &md)
void BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
void BKE_modifier_free(ModifierData *md)
ModifierData * BKE_modifier_new(int type)
General operations, lookup, etc. for blender objects.
void BKE_object_free_particlesystems(Object *ob)
ParticleSystem * BKE_object_copy_particlesystem(ParticleSystem *psys, int flag)
struct ModifierData * object_add_particle_system(struct Main *bmain, const struct Scene *scene, struct Object *ob, const char *name)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname) ATTR_NONNULL(1
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
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_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
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 ParticleSystem * psys_get_current(struct Object *ob)
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, 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 ParticleSettings * BKE_particlesettings_add(struct Main *bmain, 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(const 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)
#define LISTBASE_FOREACH(type, var, list)
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])
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 mat[4][4], const float vec[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
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])
#define SNPRINTF(dst, format,...)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ eModifierType_ParticleSystem
@ eModifierType_DynamicPaint
void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
ParticleEditSettings * PE_settings(Scene *scene)
bool ED_operator_object_active_local_editable(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 Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture 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
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
draw_view in_light_buf[] float
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
Object * context_object(const bContext *C)
Object * context_active_object(const bContext *C)
void recalc_emitter_field(Depsgraph *, Object *, 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 bool duplicate_particle_systems_poll(bContext *C)
static int copy_particle_systems_exec(bContext *C, wmOperator *op)
static int remove_particle_dupliob_exec(bContext *C, wmOperator *)
void PARTICLE_OT_target_move_up(wmOperatorType *ot)
void PARTICLE_OT_dupliob_copy(wmOperatorType *ot)
void PARTICLE_OT_dupliob_refresh(wmOperatorType *ot)
static int dupliob_move_down_exec(bContext *C, wmOperator *)
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(wmOperatorType *ot)
void PARTICLE_OT_new_target(wmOperatorType *ot)
static int new_particle_settings_exec(bContext *C, wmOperator *)
static int copy_particle_dupliob_exec(bContext *C, wmOperator *)
void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
static bool psys_poll(bContext *C)
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)
static int target_move_up_exec(bContext *C, wmOperator *)
void PARTICLE_OT_dupliob_remove(wmOperatorType *ot)
static int new_particle_target_exec(bContext *C, wmOperator *)
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 void remove_particle_systems_from_object(Object *ob_to)
static int disconnect_hair_exec(bContext *C, wmOperator *op)
static int target_move_down_exec(bContext *C, wmOperator *)
static int duplicate_particle_systems_exec(bContext *C, wmOperator *op)
static int remove_particle_target_exec(bContext *C, wmOperator *)
void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot)
#define PSYS_FROM_NEXT(cur)
static int particle_system_add_exec(bContext *C, wmOperator *)
static int dupliob_move_up_exec(bContext *C, wmOperator *)
static int dupliob_refresh_exec(bContext *C, wmOperator *)
void OBJECT_OT_particle_system_add(wmOperatorType *ot)
void PARTICLE_OT_target_move_down(wmOperatorType *ot)
static int particle_system_remove_exec(bContext *C, wmOperator *)
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_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static const EnumPropertyItem space_items[]
BVHTree_NearestPointCallback nearest_callback
MeshRuntimeHandle * runtime
struct ModifierData * next
struct PTCacheEditKey * keys
struct ParticleCacheKey ** pathcache
PTCacheEditPoint * points
struct ParticleSystem * psys
struct ParticleSystem * psys
struct Mesh * mesh_original
struct PTCacheEdit * edit
struct ParticleSystem * next
struct ParticleTarget * prev
struct ParticleTarget * next
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)