Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle.c
| Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | Object *psys_find_object(Scene *scene, ParticleSystem *psys) | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| #endif | #endif | ||||
| struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData *sim) | struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData *sim) | ||||
| { | { | ||||
| struct LatticeDeformData *lattice_deform_data = NULL; | struct LatticeDeformData *lattice_deform_data = NULL; | ||||
| if (psys_in_edit_mode(sim->eval_ctx->scene_layer, sim->psys) == 0) { | if (psys_in_edit_mode(sim->eval_ctx->view_layer, sim->psys) == 0) { | ||||
| Object *lattice = NULL; | Object *lattice = NULL; | ||||
| ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys); | ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys); | ||||
| int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime; | int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime; | ||||
| for (; md; md = md->next) { | for (; md; md = md->next) { | ||||
| if (md->type == eModifierType_Lattice) { | if (md->type == eModifierType_Lattice) { | ||||
| if (md->mode & mode) { | if (md->mode & mode) { | ||||
| LatticeModifierData *lmd = (LatticeModifierData *)md; | LatticeModifierData *lmd = (LatticeModifierData *)md; | ||||
| Show All 20 Lines | |||||
| void psys_enable_all(Object *ob) | void psys_enable_all(Object *ob) | ||||
| { | { | ||||
| ParticleSystem *psys = ob->particlesystem.first; | ParticleSystem *psys = ob->particlesystem.first; | ||||
| for (; psys; psys = psys->next) | for (; psys; psys = psys->next) | ||||
| psys->flag &= ~PSYS_DISABLED; | psys->flag &= ~PSYS_DISABLED; | ||||
| } | } | ||||
| bool psys_in_edit_mode(SceneLayer *scene_layer, ParticleSystem *psys) | bool psys_in_edit_mode(ViewLayer *view_layer, ParticleSystem *psys) | ||||
| { | { | ||||
| return (scene_layer->basact && | return (view_layer->basact && | ||||
| (scene_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) && | (view_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) && | ||||
| psys == psys_get_current((scene_layer->basact)->object) && | psys == psys_get_current((view_layer->basact)->object) && | ||||
| (psys->edit || psys->pointcache->edit) && | (psys->edit || psys->pointcache->edit) && | ||||
| !psys->renderdata); | !psys->renderdata); | ||||
| } | } | ||||
| bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_params) | bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_params) | ||||
| { | { | ||||
| ParticleSystemModifierData *psmd; | ParticleSystemModifierData *psmd; | ||||
| ▲ Show 20 Lines • Show All 1,787 Lines • ▼ Show 20 Lines | static bool psys_thread_context_init_path( | ||||
| ParticleSettings *part = psys->part; | ParticleSettings *part = psys->part; | ||||
| int totparent = 0, between = 0; | int totparent = 0, between = 0; | ||||
| int segments = 1 << part->draw_step; | int segments = 1 << part->draw_step; | ||||
| int totchild = psys->totchild; | int totchild = psys->totchild; | ||||
| psys_thread_context_init(ctx, sim); | psys_thread_context_init(ctx, sim); | ||||
| /*---start figuring out what is actually wanted---*/ | /*---start figuring out what is actually wanted---*/ | ||||
| if (psys_in_edit_mode(sim->eval_ctx->scene_layer, psys)) { | if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) { | ||||
| ParticleEditSettings *pset = &scene->toolsettings->particle; | ParticleEditSettings *pset = &scene->toolsettings->particle; | ||||
| if ((psys->renderdata == 0 && use_render_params == 0) && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) | if ((psys->renderdata == 0 && use_render_params == 0) && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) | ||||
| totchild = 0; | totchild = 0; | ||||
| segments = 1 << pset->draw_step; | segments = 1 << pset->draw_step; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
| /* note: this function must be thread safe, except for branching! */ | /* note: this function must be thread safe, except for branching! */ | ||||
| static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cpa, ParticleCacheKey *child_keys, int i) | static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cpa, ParticleCacheKey *child_keys, int i) | ||||
| { | { | ||||
| ParticleThreadContext *ctx = task->ctx; | ParticleThreadContext *ctx = task->ctx; | ||||
| Object *ob = ctx->sim.ob; | Object *ob = ctx->sim.ob; | ||||
| ParticleSystem *psys = ctx->sim.psys; | ParticleSystem *psys = ctx->sim.psys; | ||||
| ParticleSettings *part = psys->part; | ParticleSettings *part = psys->part; | ||||
| ParticleCacheKey **cache = psys->childcache; | ParticleCacheKey **cache = psys->childcache; | ||||
| ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx->scene_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache; | ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx->view_layer, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache; | ||||
| ParticleCacheKey *child, *key[4]; | ParticleCacheKey *child, *key[4]; | ||||
| ParticleTexture ptex; | ParticleTexture ptex; | ||||
| float *cpa_fuv = 0, *par_rot = 0, rot[4]; | float *cpa_fuv = 0, *par_rot = 0, rot[4]; | ||||
| float orco[3], ornor[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3]; | float orco[3], ornor[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3]; | ||||
| float eff_length, eff_vec[3], weight[4]; | float eff_length, eff_vec[3], weight[4]; | ||||
| int k, cpa_num; | int k, cpa_num; | ||||
| short cpa_from; | short cpa_from; | ||||
| ▲ Show 20 Lines • Show All 392 Lines • ▼ Show 20 Lines | void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_render_params) | ||||
| float *vg_effector = NULL; | float *vg_effector = NULL; | ||||
| float *vg_length = NULL, pa_length = 1.0f; | float *vg_length = NULL, pa_length = 1.0f; | ||||
| int keyed, baked; | int keyed, baked; | ||||
| /* we don't have anything valid to create paths from so let's quit here */ | /* we don't have anything valid to create paths from so let's quit here */ | ||||
| if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) | if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) | ||||
| return; | return; | ||||
| if (psys_in_edit_mode(sim->eval_ctx->scene_layer, psys)) | if (psys_in_edit_mode(sim->eval_ctx->view_layer, psys)) | ||||
| if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) | if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) | ||||
| return; | return; | ||||
| keyed = psys->flag & PSYS_KEYED; | keyed = psys->flag & PSYS_KEYED; | ||||
| baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR; | baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR; | ||||
| /* clear out old and create new empty path cache */ | /* clear out old and create new empty path cache */ | ||||
| psys_free_path_cache(psys, psys->edit); | psys_free_path_cache(psys, psys->edit); | ||||
| ▲ Show 20 Lines • Show All 1,166 Lines • ▼ Show 20 Lines | else { | ||||
| pa = psys->particles + p; | pa = psys->particles + p; | ||||
| pind.keyed = keyed; | pind.keyed = keyed; | ||||
| pind.cache = cached ? psys->pointcache : NULL; | pind.cache = cached ? psys->pointcache : NULL; | ||||
| pind.epoint = NULL; | pind.epoint = NULL; | ||||
| pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); | pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); | ||||
| /* pind.dm disabled in editmode means we don't get effectors taken into | /* pind.dm disabled in editmode means we don't get effectors taken into | ||||
| * account when subdividing for instance */ | * account when subdividing for instance */ | ||||
| pind.dm = psys_in_edit_mode(sim->eval_ctx->scene_layer, psys) ? NULL : psys->hair_out_dm; | pind.dm = psys_in_edit_mode(sim->eval_ctx->view_layer, psys) ? NULL : psys->hair_out_dm; | ||||
| init_particle_interpolation(sim->ob, psys, pa, &pind); | init_particle_interpolation(sim->ob, psys, pa, &pind); | ||||
| do_particle_interpolation(psys, p, pa, t, &pind, state); | do_particle_interpolation(psys, p, pa, t, &pind, state); | ||||
| if (pind.dm) { | if (pind.dm) { | ||||
| mul_m4_v3(sim->ob->obmat, state->co); | mul_m4_v3(sim->ob->obmat, state->co); | ||||
| mul_mat3_m4_v3(sim->ob->obmat, state->vel); | mul_mat3_m4_v3(sim->ob->obmat, state->vel); | ||||
| } | } | ||||
| else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { | else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { | ||||
| ▲ Show 20 Lines • Show All 588 Lines • Show Last 20 Lines | |||||