Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_object.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_particle.h" | #include "ED_particle.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "physics_intern.h" | #include "physics_intern.h" | ||||
| /********************** particle system slot operators *********************/ | /********************** particle system slot operators *********************/ | ||||
| static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int particle_system_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob= ED_object_context(C); | Object *ob= ED_object_context(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| eParticleSettingsType type; | |||||
| if (!scene || !ob) | if (!scene || !ob) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| object_add_particle_system(scene, ob, NULL); | type = RNA_enum_get(op->ptr, "type"); | ||||
| object_add_particle_system(scene, ob, NULL, type); | |||||
| WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); | WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); | ||||
| WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); | WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void OBJECT_OT_particle_system_add(wmOperatorType *ot) | void OBJECT_OT_particle_system_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add Particle System Slot"; | ot->name = "Add Particle System Slot"; | ||||
| ot->idname = "OBJECT_OT_particle_system_add"; | ot->idname = "OBJECT_OT_particle_system_add"; | ||||
| ot->description = "Add a particle system"; | ot->description = "Add a particle system"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->poll = ED_operator_object_active_editable; | ot->poll = ED_operator_object_active_editable; | ||||
| ot->exec = particle_system_add_exec; | ot->exec = particle_system_add_exec; | ||||
| ot->invoke = WM_menu_invoke; | |||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", particle_settings_user_type_items, PART_EMITTER, "Type", "Particle Type"); | |||||
| } | } | ||||
| static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) | static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *ob = ED_object_context(C); | Object *ob = ED_object_context(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| int mode_orig; | int mode_orig; | ||||
| Show All 38 Lines | |||||
| /********************** new particle settings operator *********************/ | /********************** new particle settings operator *********************/ | ||||
| static int psys_poll(bContext *C) | static int psys_poll(bContext *C) | ||||
| { | { | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | ||||
| return (ptr.data != NULL); | return (ptr.data != NULL); | ||||
| } | } | ||||
| static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) | static int new_particle_settings_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain= CTX_data_main(C); | Main *bmain= CTX_data_main(C); | ||||
| ParticleSystem *psys; | ParticleSystem *psys; | ||||
| ParticleSettings *part = NULL; | ParticleSettings *part = NULL; | ||||
| Object *ob; | Object *ob; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| eParticleSettingsType type = RNA_enum_get(op->ptr, "type"); | |||||
| ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | ||||
| psys = ptr.data; | psys = ptr.data; | ||||
| /* add or copy particle setting */ | /* add or copy particle setting */ | ||||
| if (psys->part) | if (psys->part) | ||||
| part= BKE_particlesettings_copy(psys->part); | part= BKE_particlesettings_copy_ex(psys->part, type); | ||||
| else | else { | ||||
| part= psys_new_settings("ParticleSettings", bmain); | part= psys_new_settings("ParticleSettings", bmain, type); | ||||
| } | |||||
| ob= ptr.id.data; | ob= ptr.id.data; | ||||
| if (psys->part) | if (psys->part) | ||||
| psys->part->id.us--; | psys->part->id.us--; | ||||
| psys->part = part; | psys->part = part; | ||||
| Show All 11 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "New Particle Settings"; | ot->name = "New Particle Settings"; | ||||
| ot->idname = "PARTICLE_OT_new"; | ot->idname = "PARTICLE_OT_new"; | ||||
| ot->description = "Add new particle settings"; | ot->description = "Add new particle settings"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = new_particle_settings_exec; | ot->exec = new_particle_settings_exec; | ||||
| ot->invoke = WM_menu_invoke; | |||||
| ot->poll = psys_poll; | ot->poll = psys_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", particle_settings_user_type_items, PART_EMITTER, "Type", "Particle Type"); | |||||
| } | } | ||||
| /********************** keyed particle target operators *********************/ | /********************** keyed particle target operators *********************/ | ||||
| static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) | static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); | ||||
| ▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines | |||||