diff options
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 10 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 128 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 42 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 17 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 4 |
5 files changed, 79 insertions, 122 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 5d928d69da2..6dee6825b31 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -294,8 +294,6 @@ typedef struct DynamicPaintBakeJob { DynamicPaintSurface *surface; DynamicPaintCanvasSettings *canvas; - EvaluationContext *eval_ctx; - int success; double start; } DynamicPaintBakeJob; @@ -315,8 +313,6 @@ static void dpaint_bake_endjob(void *customdata) dynamicPaint_freeSurfaceData(job->surface); - MEM_freeN(job->eval_ctx); - G.is_rendering = false; BKE_spacedata_draw_locks(false); @@ -391,7 +387,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* calculate a frame */ scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, job->depsgraph); - if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) { + if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) { job->success = 0; return; } @@ -459,9 +455,6 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) DynamicPaintCanvasSettings *canvas; Object *ob = ED_object_context(C); Scene *scene = CTX_data_scene(C); - EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext"); - - CTX_data_eval_ctx(C, eval_ctx); DynamicPaintSurface *surface; @@ -493,7 +486,6 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) job->ob = ob; job->canvas = canvas; job->surface = surface; - job->eval_ctx = eval_ctx; wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Dynamic Paint Bake", WM_JOB_PROGRESS, diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index b4f917abc74..7012046fc31 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -194,7 +194,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br * note: this function runs on poll, therefor it can runs many times a second * keep it fast! */ static PTCacheEdit *pe_get_current( - const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int create) + Depsgraph *depsgraph, Scene *scene, Object *ob, int create) { ParticleEditSettings *pset= PE_settings(scene); PTCacheEdit *edit = NULL; @@ -233,18 +233,18 @@ static PTCacheEdit *pe_get_current( if (psys->part && psys->part->type == PART_HAIR) { if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) { if (create && !psys->pointcache->edit) - PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL); + PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); edit = pid->cache->edit; } else { if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE) - PE_create_particle_edit(eval_ctx, scene, ob, NULL, psys); + PE_create_particle_edit(depsgraph, scene, ob, NULL, psys); edit = psys->edit; } } else { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) - PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, psys); + PE_create_particle_edit(depsgraph, scene, ob, pid->cache, psys); edit = pid->cache->edit; } @@ -255,7 +255,7 @@ static PTCacheEdit *pe_get_current( if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { pset->flag |= PE_FADE_TIME; // NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; - PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL); + PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -264,7 +264,7 @@ static PTCacheEdit *pe_get_current( if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { pset->flag |= PE_FADE_TIME; // NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; - PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL); + PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -284,15 +284,15 @@ PTCacheEdit *PE_get_current(Scene *scene, Object *ob) return pe_get_current(NULL, scene, ob, 0); } -PTCacheEdit *PE_create_current(const EvaluationContext *eval_ctx, Scene *scene, Object *ob) +PTCacheEdit *PE_create_current(Depsgraph *depsgraph, Scene *scene, Object *ob) { - return pe_get_current(eval_ctx, scene, ob, 1); + return pe_get_current(depsgraph, scene, ob, 1); } -void PE_current_changed(const EvaluationContext *eval_ctx, Scene *scene, Object *ob) +void PE_current_changed(Depsgraph *depsgraph, Scene *scene, Object *ob) { if (ob->mode == OB_MODE_PARTICLE_EDIT) { - PE_create_current(eval_ctx, scene, ob); + PE_create_current(depsgraph, scene, ob); } } @@ -343,7 +343,7 @@ typedef struct PEData { DerivedMesh *dm; PTCacheEdit *edit; BVHTreeFromMesh shape_bvh; - EvaluationContext eval_ctx; + Depsgraph *depsgraph; const int *mval; rcti *rect; @@ -376,7 +376,7 @@ static void PE_set_data(bContext *C, PEData *data) data->scene = CTX_data_scene(C); data->view_layer = CTX_data_view_layer(C); data->ob = CTX_data_active_object(C); - CTX_data_eval_ctx(C, &data->eval_ctx); + data->depsgraph = CTX_data_depsgraph(C); data->edit = PE_get_current(data->scene, data->ob); } @@ -391,7 +391,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data) /* needed or else the draw matrix can be incorrect */ view3d_operator_needs_opengl(C); - ED_view3d_backbuf_validate(&data->eval_ctx, &data->vc); + ED_view3d_backbuf_validate(&data->vc); /* we may need to force an update here by setting the rv3d as dirty * for now it seems ok, but take care!: * rv3d->depths->dirty = 1; */ @@ -1136,7 +1136,7 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys) BLI_kdtree_balance(edit->emitter_field); } -static void PE_update_selection(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int useflag) +static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag) { PTCacheEdit *edit = PE_get_current(scene, ob); HairKey *hkey; @@ -1157,7 +1157,7 @@ static void PE_update_selection(const EvaluationContext *eval_ctx, Scene *scene, } } - psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering); + psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering); /* disable update flag */ @@ -1243,7 +1243,7 @@ static void update_velocities(PTCacheEdit *edit) } } -void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int useflag) +void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag) { /* use this to do partial particle updates, not usable when adding or * removing, then a full redo is necessary and calling this may crash */ @@ -1273,7 +1273,7 @@ void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, Object *o PE_hide_keys_time(scene, edit, CFRA); /* regenerate path caches */ - psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering); + psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering); /* disable update flag */ LOOP_POINTS { @@ -1385,8 +1385,7 @@ static void select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in static int pe_select_all_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; @@ -1411,7 +1410,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op) } } - PE_update_selection(&eval_ctx, scene, ob, 1); + PE_update_selection(depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1468,7 +1467,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec else for_mouse_hit_keys(&data, toggle_key_select, 1); - PE_update_selection(&data.eval_ctx, scene, ob, 1); + PE_update_selection(data.depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1509,7 +1508,7 @@ static int select_roots_exec(bContext *C, wmOperator *op) data.select_action = action; foreach_point(&data, select_root); - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1574,7 +1573,7 @@ static int select_tips_exec(bContext *C, wmOperator *op) data.select_action = action; foreach_point(&data, select_tip); - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1658,7 +1657,7 @@ static int select_random_exec(bContext *C, wmOperator *op) BLI_rng_free(rng); - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1702,7 +1701,7 @@ static int select_linked_exec(bContext *C, wmOperator *op) data.select= !RNA_boolean_get(op->ptr, "deselect"); for_mouse_hit_keys(&data, select_keys, 1); /* nearest only */ - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1766,7 +1765,7 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend) for_mouse_hit_keys(&data, select_key, 0); - PE_update_selection(&data.eval_ctx, scene, ob, 1); + PE_update_selection(data.depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1791,7 +1790,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) for_mouse_hit_keys(&data, select_key, 0); - PE_update_selection(&data.eval_ctx, scene, ob, 1); + PE_update_selection(data.depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1879,7 +1878,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool } } - PE_update_selection(&data.eval_ctx, scene, ob, 1); + PE_update_selection(data.depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1891,8 +1890,7 @@ static int hide_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); Scene *scene= CTX_data_scene(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + Depsgraph *depsgraph = CTX_data_depsgraph(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; @@ -1917,7 +1915,7 @@ static int hide_exec(bContext *C, wmOperator *op) } } - PE_update_selection(&eval_ctx, scene, ob, 1); + PE_update_selection(depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1947,8 +1945,7 @@ static int reveal_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); Scene *scene= CTX_data_scene(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + Depsgraph *depsgraph = CTX_data_depsgraph(C); PTCacheEdit *edit= PE_get_current(scene, ob); const bool select = RNA_boolean_get(op->ptr, "select"); POINT_P; KEY_K; @@ -1964,7 +1961,7 @@ static int reveal_exec(bContext *C, wmOperator *op) } } - PE_update_selection(&eval_ctx, scene, ob, 1); + PE_update_selection(depsgraph, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -2026,7 +2023,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) PE_set_data(C, &data); foreach_point(&data, select_less_keys); - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -2088,7 +2085,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) PE_set_data(C, &data); foreach_point(&data, select_more_keys); - PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1); + PE_update_selection(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -2121,12 +2118,10 @@ static void rekey_particle(PEData *data, int pa_index) ParticleKey state; HairKey *key, *new_keys, *okey; PTCacheEditKey *ekey; - EvaluationContext eval_ctx; float dval, sta, end; int k; - CTX_data_eval_ctx(data->context, &eval_ctx); - sim.eval_ctx = &eval_ctx; + sim.depsgraph = data->depsgraph; sim.scene = data->scene; sim.ob = data->ob; sim.psys = edit->psys; @@ -2180,9 +2175,6 @@ static int rekey_exec(bContext *C, wmOperator *op) { PEData data; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - PE_set_data(C, &data); data.dval= 1.0f / (float)(data.totrekey-1); @@ -2191,7 +2183,7 @@ static int rekey_exec(bContext *C, wmOperator *op) foreach_selected_point(&data, rekey_particle); recalc_lengths(data.edit); - PE_update_object(&eval_ctx, data.scene, data.ob, 1); + PE_update_object(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); return OPERATOR_FINISHED; @@ -2225,16 +2217,13 @@ static void rekey_particle_to_time(const bContext *C, Scene *scene, Object *ob, ParticleKey state; HairKey *new_keys, *key; PTCacheEditKey *ekey; - EvaluationContext eval_ctx; int k; - CTX_data_eval_ctx(C, &eval_ctx); - if (!edit || !edit->psys) return; psys = edit->psys; - sim.eval_ctx = &eval_ctx; + sim.depsgraph = CTX_data_depsgraph(C); sim.scene = scene; sim.ob = ob; sim.psys = psys; @@ -2447,14 +2436,12 @@ static void subdivide_particle(PEData *data, int pa_index) ParticleKey state; HairKey *key, *nkey, *new_keys; PTCacheEditKey *ekey, *nekey, *new_ekeys; - EvaluationContext eval_ctx; int k; short totnewkey=0; float endtime; - CTX_data_eval_ctx(data->context, &eval_ctx); - sim.eval_ctx = &eval_ctx; + sim.depsgraph = data->depsgraph; sim.scene = data->scene; sim.ob = data->ob; sim.psys = edit->psys; @@ -2525,14 +2512,11 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op)) { PEData data; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - PE_set_data(C, &data); foreach_point(&data, subdivide_particle); recalc_lengths(data.edit); - PE_update_object(&eval_ctx, data.scene, data.ob, 1); + PE_update_object(data.depsgraph, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); return OPERATOR_FINISHED; @@ -3356,21 +3340,19 @@ static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, De float *face_minmax, float *pa_minmax, float radius, float *ipoint) { - EvaluationContext eval_ctx; + Depsgraph *depsgraph = CTX_data_depsgraph(C); MFace *mface= NULL; MVert *mvert= NULL; int i, totface, intersect=0; float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3]; float cur_ipoint[3]; - CTX_data_eval_ctx(C, &eval_ctx); - if (dm == NULL) { psys_disable_all(ob); - dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0); + dm = mesh_get_derived_final(depsgraph, scene, ob, 0); if (dm == NULL) - dm = mesh_get_derived_deform(&eval_ctx, scene, ob, 0); + dm = mesh_get_derived_deform(depsgraph, scene, ob, 0); psys_enable_all(ob); @@ -3485,8 +3467,7 @@ static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, De static int brush_add(const bContext *C, PEData *data, short number) { - EvaluationContext eval_ctx; - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene= data->scene; Object *ob= data->ob; DerivedMesh *dm; @@ -3514,9 +3495,7 @@ static int brush_add(const bContext *C, PEData *data, short number) rng = BLI_rng_new_srandom(psys->seed+data->mval[0]+data->mval[1]); - CTX_data_eval_ctx(C, &eval_ctx); - - sim.eval_ctx = &eval_ctx; + sim.depsgraph = depsgraph; sim.scene= scene; sim.ob= ob; sim.psys= psys; @@ -3805,8 +3784,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if (!PE_start_edit(edit)) return; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + Depsgraph *depsgraph = CTX_data_depsgraph(C); RNA_float_get_array(itemptr, "mouse", mousef); mouse[0] = mousef[0]; @@ -3991,7 +3969,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - PE_update_object(&eval_ctx, scene, ob, 1); + PE_update_object(depsgraph, scene, ob, 1); } } @@ -4254,7 +4232,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - PE_update_object(&data.eval_ctx, scene, ob, 1); + PE_update_object(data.depsgraph, scene, ob, 1); } if (edit->psys) { @@ -4331,7 +4309,7 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3]) /* initialize needed data for bake edit */ void PE_create_particle_edit( - const EvaluationContext *eval_ctx, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys) + Depsgraph *depsgraph, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys) { PTCacheEdit *edit; ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL; @@ -4433,7 +4411,7 @@ void PE_create_particle_edit( if (psys && !cache) recalc_emitter_field(ob, psys); - PE_update_object(eval_ctx, scene, ob, 1); + PE_update_object(depsgraph, scene, ob, 1); } } @@ -4455,6 +4433,7 @@ static int particle_edit_toggle_poll(bContext *C) static int particle_edit_toggle_exec(bContext *C, wmOperator *op) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_PARTICLE_EDIT; @@ -4468,11 +4447,9 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) if (!is_mode_set) { PTCacheEdit *edit; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); ob->mode |= mode_flag; - edit= PE_create_current(&eval_ctx, scene, ob); + edit= PE_create_current(depsgraph, scene, ob); /* mesh may have changed since last entering editmode. * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ @@ -4642,8 +4619,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + Depsgraph *depsgraph = CTX_data_depsgraph(C); PTCacheEdit *edit = PE_get_current(scene, ob); float average_length = calculate_average_length(edit); @@ -4654,7 +4630,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) scale_points_to_length(edit, average_length); - PE_update_object(&eval_ctx, scene, ob, 1); + PE_update_object(depsgraph, scene, ob, 1); if (edit->psys) { WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index e87de1a6875..23a6ba68fc9 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -546,7 +546,7 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot) /************************ connect/disconnect hair operators *********************/ static void disconnect_hair( - const EvaluationContext *eval_ctx, Scene *scene, + Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); @@ -593,30 +593,28 @@ static void disconnect_hair( if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) pset->brushtype = PE_BRUSH_NONE; - PE_update_object(eval_ctx, scene, ob, 0); + PE_update_object(depsgraph, scene, ob, 0); } static int disconnect_hair_exec(bContext *C, wmOperator *op) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene= CTX_data_scene(C); Object *ob= ED_object_context(C); ParticleSystem *psys= NULL; const bool all = RNA_boolean_get(op->ptr, "all"); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (!ob) return OPERATOR_CANCELLED; if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - disconnect_hair(&eval_ctx, scene, ob, psys); + disconnect_hair(depsgraph, scene, ob, psys); } } else { psys = psys_get_current(ob); - disconnect_hair(&eval_ctx, scene, ob, psys); + disconnect_hair(depsgraph, scene, ob, psys); } DEG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -643,7 +641,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) * from/to_mat : additional transform for from/to particles (e.g. for using object space copying) */ static bool remap_hair_emitter( - const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, + Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit, float from_mat[4][4], float to_mat[4][4], bool from_global, bool to_global) { @@ -829,13 +827,13 @@ static bool remap_hair_emitter( psys_free_path_cache(target_psys, target_edit); - PE_update_object(eval_ctx, scene, target_ob, 0); + PE_update_object(depsgraph, scene, target_ob, 0); return true; } static bool connect_hair( - const EvaluationContext *eval_ctx, Scene *scene, + Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys) { bool ok; @@ -844,7 +842,7 @@ static bool connect_hair( return false; ok = remap_hair_emitter( - eval_ctx, scene, ob, psys, ob, psys, psys->edit, + depsgraph, scene, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); psys->flag &= ~PSYS_GLOBAL_HAIR; @@ -853,7 +851,7 @@ static bool connect_hair( static int connect_hair_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene= CTX_data_scene(C); Object *ob= ED_object_context(C); ParticleSystem *psys= NULL; @@ -863,16 +861,14 @@ static int connect_hair_exec(bContext *C, wmOperator *op) if (!ob) return OPERATOR_CANCELLED; - CTX_data_eval_ctx(C, &eval_ctx); - if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - any_connected |= connect_hair(&eval_ctx, scene, ob, psys); + any_connected |= connect_hair(depsgraph, scene, ob, psys); } } else { psys = psys_get_current(ob); - any_connected |= connect_hair(&eval_ctx, scene, ob, psys); + any_connected |= connect_hair(depsgraph, scene, ob, psys); } if (!any_connected) { @@ -909,7 +905,7 @@ typedef enum eCopyParticlesSpace { } eCopyParticlesSpace; static void copy_particle_edit( - const EvaluationContext *eval_ctx, Scene *scene, + Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from) { PTCacheEdit *edit_from = psys_from->edit, *edit; @@ -957,7 +953,7 @@ static void copy_particle_edit( recalc_lengths(edit); recalc_emitter_field(ob, psys); - PE_update_object(eval_ctx, scene, ob, true); + PE_update_object(depsgraph, scene, ob, true); } static void remove_particle_systems_from_object(Object *ob_to) @@ -994,15 +990,13 @@ static bool copy_particle_systems_to_object(const bContext *C, bool duplicate_settings) { Main *bmain = CTX_data_main(C); - EvaluationContext eval_ctx; + Depsgraph *depsgraph = CTX_data_depsgraph(C); ModifierData *md; ParticleSystem *psys_start = NULL, *psys, *psys_from; ParticleSystem **tmp_psys; DerivedMesh *final_dm; CustomDataMask cdmask; int i, totpsys; - - CTX_data_eval_ctx(C, &eval_ctx); if (ob_to->type != OB_MESH) return false; @@ -1042,7 +1036,7 @@ static bool copy_particle_systems_to_object(const bContext *C, psys_start = totpsys > 0 ? tmp_psys[0] : NULL; /* get the DM (psys and their modifiers have not been appended yet) */ - final_dm = mesh_get_derived_final(&eval_ctx, scene, ob_to, cdmask); + final_dm = mesh_get_derived_final(depsgraph, scene, ob_to, cdmask); /* now append psys to the object and make modifiers */ for (i = 0, psys_from = PSYS_FROM_FIRST; @@ -1071,7 +1065,7 @@ static bool copy_particle_systems_to_object(const bContext *C, DM_ensure_tessface(psmd->dm_final); if (psys_from->edit) { - copy_particle_edit(&eval_ctx, scene, ob_to, psys, psys_from); + copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from); } if (duplicate_settings) { @@ -1107,7 +1101,7 @@ static bool copy_particle_systems_to_object(const bContext *C, } if (ob_from != ob_to) { remap_hair_emitter( - &eval_ctx, scene, ob_from, psys_from, ob_to, psys, psys->edit, + depsgraph, scene, ob_from, psys_from, ob_to, psys, psys->edit, from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR); } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index c0b2ae8ded4..541242fdc09 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -246,7 +246,7 @@ static void set_channel(float *channel, float time, float *value, int i, int siz } } -static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i) +static void set_vertex_channel(Depsgraph *depsgraph, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -259,7 +259,7 @@ static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, floa if (channel == NULL) return; - initElbeemMesh(eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex); + initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex); /* don't allow mesh to change number of verts in anim sequence */ if (numVerts != fobj->numVerts) { @@ -333,14 +333,11 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); - EvaluationContext eval_ctx; Base *base; int i; int length = channels->length; float eval_time; - CTX_data_eval_ctx(C, &eval_ctx); - /* init time values (assuming that time moves at a constant speed; may be overridden later) */ init_time(domainSettings, channels); @@ -380,7 +377,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid float *verts=NULL; int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd); - initElbeemMesh(&eval_ctx, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex); + initElbeemMesh(depsgraph, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex); fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache"); MEM_freeN(verts); @@ -468,7 +465,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid } if (fluid_is_animated_mesh(fluidmd->fss)) { - set_vertex_channel(&eval_ctx, fobj->VertexCache, timeAtFrame, scene, fobj, i); + set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i); } } } @@ -476,10 +473,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); FluidObject *fobj; - EvaluationContext eval_ctx; - - CTX_data_eval_ctx(C, &eval_ctx); for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; @@ -501,7 +496,7 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s fsmesh.type = fluidmd->fss->type; fsmesh.name = ob->id.name; - initElbeemMesh(&eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex); + initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex); fsmesh.numVertices = numVerts; fsmesh.numTriangles = numTris; diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index 246bf79360f..72da417da63 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -33,7 +33,7 @@ #ifndef __PHYSICS_INTERN_H__ #define __PHYSICS_INTERN_H__ -struct EvaluationContext; +struct Depsgraph; struct Object; struct PTCacheEdit; struct ParticleSystem; @@ -71,7 +71,7 @@ void PARTICLE_OT_edited_clear(struct wmOperatorType *ot); void PARTICLE_OT_unify_length(struct wmOperatorType *ot); void PE_create_particle_edit( - const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PointCache *cache, struct ParticleSystem *psys); void recalc_lengths(struct PTCacheEdit *edit); void recalc_emitter_field(struct Object *ob, struct ParticleSystem *psys); |