Particle system: Move runtime data to runtime field
Allows it to be preserved during copy-on-write update when on-geometry related update is needed. This is a required part for T63537, where we need to preserve the entire evaluation data when object is tagged for only RECALC_COPY_ON_WRITE. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D5023
This commit is contained in:
@@ -467,7 +467,7 @@ void psys_thread_context_init(ParticleThreadContext *ctx, ParticleSimulationData
|
||||
{
|
||||
memset(ctx, 0, sizeof(ParticleThreadContext));
|
||||
ctx->sim = *sim;
|
||||
ctx->mesh = ctx->sim.psmd->mesh_final;
|
||||
ctx->mesh = BKE_particle_modifier_mesh_final_get(ctx->sim.psmd);
|
||||
ctx->ma = give_current_material(sim->ob, sim->psys->part->omat);
|
||||
}
|
||||
|
||||
@@ -3348,6 +3348,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
|
||||
|
||||
/* make vgroup for pin roots etc.. */
|
||||
hair_index = 1;
|
||||
Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
|
||||
LOOP_PARTICLES
|
||||
{
|
||||
if (!(pa->flag & PARS_UNEXIST)) {
|
||||
@@ -3358,7 +3359,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
|
||||
pa->hair_index = hair_index;
|
||||
use_hair = psys_hair_use_simulation(pa, max_length);
|
||||
|
||||
psys_mat_hair_to_object(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
|
||||
psys_mat_hair_to_object(sim->ob, mesh_final, psys->part->from, pa, hairmat);
|
||||
mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat);
|
||||
normalize_m4(root_mat);
|
||||
|
||||
@@ -3524,7 +3525,9 @@ static void hair_step(ParticleSimulationData *sim, float cfra, const bool use_re
|
||||
|
||||
if (psys->recalc & ID_RECALC_PSYS_RESET) {
|
||||
/* need this for changing subsurf levels */
|
||||
psys_calc_dmcache(sim->ob, sim->psmd->mesh_final, sim->psmd->mesh_original, psys);
|
||||
Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
|
||||
Mesh *mesh_original = BKE_particle_modifier_mesh_original_get(sim->psmd);
|
||||
psys_calc_dmcache(sim->ob, mesh_final, mesh_original, psys);
|
||||
|
||||
if (psys->clmd) {
|
||||
cloth_free_modifier(psys->clmd);
|
||||
@@ -3576,7 +3579,8 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
|
||||
|
||||
if (pa->totkey) {
|
||||
sub_v3_v3(key->co, root->co);
|
||||
psys_vec_rot_to_face(sim->psmd->mesh_final, pa, key->co);
|
||||
Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
|
||||
psys_vec_rot_to_face(mesh_final, pa, key->co);
|
||||
}
|
||||
|
||||
key->time = pa->state.time;
|
||||
@@ -4610,12 +4614,13 @@ void particle_system_update(struct Depsgraph *depsgraph,
|
||||
}
|
||||
}
|
||||
|
||||
if (!sim.psmd->mesh_final) {
|
||||
Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim.psmd);
|
||||
if (!mesh_final) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (part->from != PART_FROM_VERT) {
|
||||
BKE_mesh_tessface_ensure(sim.psmd->mesh_final);
|
||||
BKE_mesh_tessface_ensure(mesh_final);
|
||||
}
|
||||
|
||||
/* to verify if we need to restore object afterwards */
|
||||
|
||||
Reference in New Issue
Block a user