Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_object.c
| Show First 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys) | ||||
| } | } | ||||
| if (!psys->part || psys->part->type != PART_HAIR) { | if (!psys->part || psys->part->type != PART_HAIR) { | ||||
| return; | return; | ||||
| } | } | ||||
| edit = psys->edit; | edit = psys->edit; | ||||
| point = edit ? edit->points : NULL; | point = edit ? edit->points : NULL; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd_eval); | |||||
| for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) { | for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) { | ||||
| if (point) { | if (point) { | ||||
| ekey = point->keys; | ekey = point->keys; | ||||
| point++; | point++; | ||||
| } | } | ||||
| psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, pa, hairmat); | psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat); | ||||
| for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) { | for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) { | ||||
| mul_m4_v3(hairmat, key->co); | mul_m4_v3(hairmat, key->co); | ||||
| if (ekey) { | if (ekey) { | ||||
| ekey->flag &= ~PEK_USE_WCO; | ekey->flag &= ~PEK_USE_WCO; | ||||
| ekey++; | ekey++; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static bool remap_hair_emitter(Depsgraph *depsgraph, | ||||
| MEdge *medge = NULL, *me; | MEdge *medge = NULL, *me; | ||||
| MVert *mvert; | MVert *mvert; | ||||
| Mesh *mesh, *target_mesh; | Mesh *mesh, *target_mesh; | ||||
| int numverts; | int numverts; | ||||
| int i, k; | int i, k; | ||||
| float from_ob_imat[4][4], to_ob_imat[4][4]; | float from_ob_imat[4][4], to_ob_imat[4][4]; | ||||
| float from_imat[4][4], to_imat[4][4]; | float from_imat[4][4], to_imat[4][4]; | ||||
| if (!target_psmd->mesh_final) { | Mesh *target_mesh_final = BKE_particle_modifier_mesh_final_get(target_psmd); | ||||
| if (!target_mesh_final) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| if (!psys->part || psys->part->type != PART_HAIR) { | if (!psys->part || psys->part->type != PART_HAIR) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!target_psys->part || target_psys->part->type != PART_HAIR) { | if (!target_psys->part || target_psys->part->type != PART_HAIR) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| edit_point = target_edit ? target_edit->points : NULL; | edit_point = target_edit ? target_edit->points : NULL; | ||||
| invert_m4_m4(from_ob_imat, ob->obmat); | invert_m4_m4(from_ob_imat, ob->obmat); | ||||
| invert_m4_m4(to_ob_imat, target_ob->obmat); | invert_m4_m4(to_ob_imat, target_ob->obmat); | ||||
| invert_m4_m4(from_imat, from_mat); | invert_m4_m4(from_imat, from_mat); | ||||
| invert_m4_m4(to_imat, to_mat); | invert_m4_m4(to_imat, to_mat); | ||||
| if (target_psmd->mesh_final->runtime.deformed_only) { | if (target_mesh_final->runtime.deformed_only) { | ||||
| /* we don't want to mess up target_psmd->dm when converting to global coordinates below */ | /* we don't want to mess up target_psmd->dm when converting to global coordinates below */ | ||||
| mesh = target_psmd->mesh_final; | mesh = target_mesh_final; | ||||
| } | } | ||||
| else { | else { | ||||
| mesh = target_psmd->mesh_original; | mesh = BKE_particle_modifier_mesh_original_get(target_psmd); | ||||
| } | } | ||||
| target_mesh = target_psmd->mesh_final; | target_mesh = target_mesh_final; | ||||
| if (mesh == NULL) { | if (mesh == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* don't modify the original vertices */ | /* don't modify the original vertices */ | ||||
| BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh, LIB_ID_COPY_LOCALIZE); | BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh, LIB_ID_COPY_LOCALIZE); | ||||
| /* BMESH_ONLY, deform dm may not have tessface */ | /* BMESH_ONLY, deform dm may not have tessface */ | ||||
| BKE_mesh_tessface_ensure(mesh); | BKE_mesh_tessface_ensure(mesh); | ||||
| ▲ Show 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; | ||||
| psmd = (ParticleSystemModifierData *)md; | psmd = (ParticleSystemModifierData *)md; | ||||
| /* push on top of the stack, no use trying to reproduce old stack order */ | /* push on top of the stack, no use trying to reproduce old stack order */ | ||||
| BLI_addtail(&ob_to->modifiers, md); | BLI_addtail(&ob_to->modifiers, md); | ||||
| BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i); | BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i); | ||||
| modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd); | modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd); | ||||
| psmd->psys = psys; | psmd->psys = psys; | ||||
| BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&psmd->mesh_final, LIB_ID_COPY_LOCALIZE); | |||||
| BKE_mesh_calc_normals(psmd->mesh_final); | /* TODO(sergey): This should probably be accessing evaluated psmd. */ | ||||
| BKE_mesh_tessface_ensure(psmd->mesh_final); | ParticleSystemModifierDataRuntime *runtime = BKE_particle_modifier_runtime_ensure(psmd); | ||||
| BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&runtime->mesh_final, LIB_ID_COPY_LOCALIZE); | |||||
| BKE_mesh_calc_normals(runtime->mesh_final); | |||||
| BKE_mesh_tessface_ensure(runtime->mesh_final); | |||||
| if (psys_from->edit) { | if (psys_from->edit) { | ||||
| copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from); | copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from); | ||||
| } | } | ||||
| if (duplicate_settings) { | if (duplicate_settings) { | ||||
| id_us_min(&psys->part->id); | id_us_min(&psys->part->id); | ||||
| psys->part = BKE_particlesettings_copy(bmain, psys->part); | psys->part = BKE_particlesettings_copy(bmain, psys->part); | ||||
| ▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines | |||||