Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle.c
| Show First 20 Lines • Show All 3,476 Lines • ▼ Show 20 Lines | void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[4][4]) | ||||
| psys_mat_hair_to_object(ob, dm, from, pa, facemat); | psys_mat_hair_to_object(ob, dm, from, pa, facemat); | ||||
| mul_m4_m4m4(hairmat, ob->obmat, facemat); | mul_m4_m4m4(hairmat, ob->obmat, facemat); | ||||
| } | } | ||||
| /************************************************/ | /************************************************/ | ||||
| /* ParticleSettings handling */ | /* ParticleSettings handling */ | ||||
| /************************************************/ | /************************************************/ | ||||
| ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name) | ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name, eParticleSettingsType type) | ||||
| { | { | ||||
| ParticleSystem *psys; | ParticleSystem *psys; | ||||
| ModifierData *md; | ModifierData *md; | ||||
| ParticleSystemModifierData *psmd; | ParticleSystemModifierData *psmd; | ||||
| if (!ob || ob->type != OB_MESH) | if (!ob || ob->type != OB_MESH) | ||||
| return NULL; | return NULL; | ||||
| psys = ob->particlesystem.first; | psys = ob->particlesystem.first; | ||||
| for (; psys; psys = psys->next) | for (; psys; psys = psys->next) | ||||
| psys->flag &= ~PSYS_CURRENT; | psys->flag &= ~PSYS_CURRENT; | ||||
| psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); | psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); | ||||
| psys->pointcache = BKE_ptcache_add(&psys->ptcaches); | psys->pointcache = BKE_ptcache_add(&psys->ptcaches); | ||||
| BLI_addtail(&ob->particlesystem, psys); | BLI_addtail(&ob->particlesystem, psys); | ||||
| psys->part = psys_new_settings(DATA_("ParticleSettings"), NULL); | psys->part = psys_new_settings(DATA_("ParticleSettings"), NULL, type); | ||||
| if (BLI_countlist(&ob->particlesystem) > 1) | if (BLI_countlist(&ob->particlesystem) > 1) | ||||
| BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); | BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); | ||||
| else | else | ||||
| BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name)); | BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name)); | ||||
| md = modifier_new(eModifierType_ParticleSystem); | md = modifier_new(eModifierType_ParticleSystem); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void object_remove_particle_system(Scene *UNUSED(scene), Object *ob) | ||||
| if (ob->particlesystem.first) | if (ob->particlesystem.first) | ||||
| ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT; | ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT; | ||||
| else | else | ||||
| ob->mode &= ~OB_MODE_PARTICLE_EDIT; | ob->mode &= ~OB_MODE_PARTICLE_EDIT; | ||||
| DAG_relations_tag_update(G.main); | DAG_relations_tag_update(G.main); | ||||
| DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| static void default_particle_settings(ParticleSettings *part) | static void default_particle_settings(ParticleSettings *part, eParticleSettingsType type) | ||||
| { | { | ||||
| part->type = PART_EMITTER; | part->type = type; | ||||
| if (type == PART_HAIR) { | |||||
| part->ren_as = PART_DRAW_PATH; | |||||
| } | |||||
| else { | |||||
| part->ren_as = PART_DRAW_HALO; | |||||
| } | |||||
| part->distr = PART_DISTR_JIT; | part->distr = PART_DISTR_JIT; | ||||
| part->draw_as = PART_DRAW_REND; | part->draw_as = PART_DRAW_REND; | ||||
| part->ren_as = PART_DRAW_HALO; | |||||
| part->bb_uv_split = 1; | part->bb_uv_split = 1; | ||||
| part->bb_align = PART_BB_VIEW; | part->bb_align = PART_BB_VIEW; | ||||
| part->bb_split_offset = PART_BB_OFF_LINEAR; | part->bb_split_offset = PART_BB_OFF_LINEAR; | ||||
| part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR; | part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR; | ||||
| part->sta = 1.0; | part->sta = 1.0; | ||||
| part->end = 200.0; | part->end = 200.0; | ||||
| part->lifetime = 50.0; | part->lifetime = 50.0; | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void default_particle_settings(ParticleSettings *part, eParticleSettingsType type) | ||||
| if (!part->effector_weights) | if (!part->effector_weights) | ||||
| part->effector_weights = BKE_add_effector_weights(NULL); | part->effector_weights = BKE_add_effector_weights(NULL); | ||||
| part->omat = 1; | part->omat = 1; | ||||
| part->use_modifier_stack = false; | part->use_modifier_stack = false; | ||||
| } | } | ||||
| ParticleSettings *psys_new_settings(const char *name, Main *main) | ParticleSettings *psys_new_settings(const char *name, Main *main, eParticleSettingsType type) | ||||
| { | { | ||||
| ParticleSettings *part; | ParticleSettings *part; | ||||
| if (main == NULL) | if (main == NULL) | ||||
| main = G.main; | main = G.main; | ||||
| part = BKE_libblock_alloc(main, ID_PA, name); | part = BKE_libblock_alloc(main, ID_PA, name); | ||||
| default_particle_settings(part); | default_particle_settings(part, type); | ||||
| return part; | return part; | ||||
| } | } | ||||
| ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part) | ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part) | ||||
| { | { | ||||
| return BKE_particlesettings_copy_ex(part, part->type); | |||||
| } | |||||
| ParticleSettings *BKE_particlesettings_copy_ex(ParticleSettings *part, eParticleSettingsType type) | |||||
| { | |||||
| ParticleSettings *partn; | ParticleSettings *partn; | ||||
| int a; | int a; | ||||
| partn = BKE_libblock_copy(&part->id); | partn = BKE_libblock_copy(&part->id); | ||||
| partn->type = type; | |||||
| partn->pd = MEM_dupallocN(part->pd); | partn->pd = MEM_dupallocN(part->pd); | ||||
| partn->pd2 = MEM_dupallocN(part->pd2); | partn->pd2 = MEM_dupallocN(part->pd2); | ||||
| partn->effector_weights = MEM_dupallocN(part->effector_weights); | partn->effector_weights = MEM_dupallocN(part->effector_weights); | ||||
| partn->fluid = MEM_dupallocN(part->fluid); | partn->fluid = MEM_dupallocN(part->fluid); | ||||
| partn->boids = boid_copy_settings(part->boids); | partn->boids = boid_copy_settings(part->boids); | ||||
| for (a = 0; a < MAX_MTEX; a++) { | for (a = 0; a < MAX_MTEX; a++) { | ||||
| ▲ Show 20 Lines • Show All 1,027 Lines • Show Last 20 Lines | |||||