diff options
20 files changed, 196 insertions, 154 deletions
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index cb2438ec1f2..88e5a25958d 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -274,7 +274,8 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface); void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw); -void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis); +void BKE_ptcache_ids_from_object( + struct Main *bmain, struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis); /***************** Global funcs ****************************/ void BKE_ptcache_remove(void); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1944b01827b..01e1192eb0c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3586,11 +3586,11 @@ bool BKE_object_modifier_use_time(Object *ob, ModifierData *md) } /* set "ignore cache" flag for all caches on this object */ -static void object_cacheIgnoreClear(Object *ob, int state) +static void object_cacheIgnoreClear(Main *bmain, Object *ob, int state) { ListBase pidlist; PTCacheID *pid; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache) { @@ -3667,9 +3667,9 @@ bool BKE_object_modifier_update_subframe( if (update_mesh) { /* ignore cache clear during subframe updates * to not mess up cache validity */ - object_cacheIgnoreClear(ob, 1); + object_cacheIgnoreClear(bmain, ob, 1); BKE_object_handle_update(bmain, eval_ctx, scene, ob); - object_cacheIgnoreClear(ob, 0); + object_cacheIgnoreClear(bmain, ob, 0); } else BKE_object_where_is_calc_time(scene, ob, frame); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8d550e09b25..f96868e99ea 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1648,7 +1648,7 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *r pid->file_type = PTCACHE_FILE_PTCACHE; } -void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis) +void BKE_ptcache_ids_from_object(Main *bmain, ListBase *lb, Object *ob, Scene *scene, int duplis) { PTCacheID *pid; ParticleSystem *psys; @@ -1719,12 +1719,12 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup if (scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) { ListBase *lb_dupli_ob; /* don't update the dupli groups, we only want their pid's */ - if ((lb_dupli_ob = object_duplilist_ex(G.main, G.main->eval_ctx, scene, ob, false))) { + if ((lb_dupli_ob = object_duplilist_ex(bmain, bmain->eval_ctx, scene, ob, false))) { DupliObject *dob; for (dob= lb_dupli_ob->first; dob; dob= dob->next) { if (dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */ ListBase lb_dupli_pid; - BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis); + BKE_ptcache_ids_from_object(bmain, &lb_dupli_pid, dob->ob, scene, duplis); BLI_movelisttolist(lb, &lb_dupli_pid); if (lb_dupli_pid.first) printf("Adding Dupli\n"); @@ -3572,7 +3572,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) /* get all pids from the object and search for smoke low res */ ListBase pidlist2; PTCacheID *pid2; - BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist2, pid->ob, scene, MAX_DUPLI_RECUR); for (pid2=pidlist2.first; pid2; pid2=pid2->next) { if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) { if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) { @@ -3607,7 +3607,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) else { for (SETLOOPER(scene, sce_iter, base)) { /* cache/bake everything in the scene */ - BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist, base->object, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { cache = pid->cache; @@ -3661,7 +3661,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) stime = ptime = PIL_check_seconds_timer(); for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) { - BKE_scene_update_for_newframe(G.main->eval_ctx, bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay); if (baker->update_progress) { float progress = ((float)(CFRA - startframe)/(float)(endframe - startframe)); @@ -3717,7 +3717,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) } else { for (SETLOOPER(scene, sce_iter, base)) { - BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist, base->object, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { /* skip hair particles */ diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 4f6aa1cc702..395eddf3edd 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -45,15 +45,15 @@ void PE_free_ptcache_edit(struct PTCacheEdit *edit); int PE_start_edit(struct PTCacheEdit *edit); /* access */ -struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob); -struct PTCacheEdit *PE_create_current(struct Scene *scene, struct Object *ob); -void PE_current_changed(struct Scene *scene, struct Object *ob); -int PE_minmax(struct Scene *scene, float min[3], float max[3]); +struct PTCacheEdit *PE_get_current(struct Main *bmain, struct Scene *scene, struct Object *ob); +struct PTCacheEdit *PE_create_current(struct Main *bmain, struct Scene *scene, struct Object *ob); +void PE_current_changed(struct Main *bmain, struct Scene *scene, struct Object *ob); +int PE_minmax(struct Main *bmain, struct Scene *scene, float min[3], float max[3]); struct ParticleEditSettings *PE_settings(struct Scene *scene); /* update calls */ void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra); -void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); +void PE_update_object(struct Main *bmain, struct Scene *scene, struct Object *ob, int useflag); /* selection tools */ int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 192ef8e550d..dc936ec8eff 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -471,7 +471,7 @@ bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int f scene->obedit = NULL; // XXX for context /* flag object caches as outdated */ - BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, obedit, scene, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ pid->cache->flag |= PTCACHE_OUTDATED; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 2a15fb21fb8..41310f86807 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -55,6 +55,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_object.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" @@ -87,17 +88,19 @@ int PE_poll(bContext *C) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - return (PE_get_current(scene, ob) != NULL); + return (PE_get_current(bmain, scene, ob) != NULL); } int PE_hair_poll(bContext *C) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit; @@ -105,7 +108,7 @@ int PE_hair_poll(bContext *C) if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - edit= PE_get_current(scene, ob); + edit= PE_get_current(bmain, scene, ob); return (edit && edit->psys); } @@ -188,7 +191,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(Scene *scene, Object *ob, int create) +static PTCacheEdit *pe_get_current(Main *bmain, Scene *scene, Object *ob, int create) { ParticleEditSettings *pset= PE_settings(scene); PTCacheEdit *edit = NULL; @@ -201,7 +204,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) pset->scene = scene; pset->object = ob; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); /* in the case of only one editable thing, set pset->edittype accordingly */ if (BLI_listbase_is_single(&pidlist)) { @@ -227,18 +230,18 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) 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(scene, ob, pid->cache, NULL); + PE_create_particle_edit(bmain, scene, ob, pid->cache, NULL); edit = pid->cache->edit; } else { if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE) - PE_create_particle_edit(scene, ob, NULL, psys); + PE_create_particle_edit(bmain, scene, ob, NULL, psys); edit = psys->edit; } } else { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) - PE_create_particle_edit(scene, ob, pid->cache, psys); + PE_create_particle_edit(bmain, scene, ob, pid->cache, psys); edit = pid->cache->edit; } @@ -249,7 +252,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) 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(scene, ob, pid->cache, NULL); + PE_create_particle_edit(bmain, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -258,7 +261,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) 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(scene, ob, pid->cache, NULL); + PE_create_particle_edit(bmain, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -273,20 +276,20 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) return edit; } -PTCacheEdit *PE_get_current(Scene *scene, Object *ob) +PTCacheEdit *PE_get_current(Main *bmain, Scene *scene, Object *ob) { - return pe_get_current(scene, ob, 0); + return pe_get_current(bmain, scene, ob, 0); } -PTCacheEdit *PE_create_current(Scene *scene, Object *ob) +PTCacheEdit *PE_create_current(Main *bmain, Scene *scene, Object *ob) { - return pe_get_current(scene, ob, 1); + return pe_get_current(bmain, scene, ob, 1); } -void PE_current_changed(Scene *scene, Object *ob) +void PE_current_changed(Main *bmain, Scene *scene, Object *ob) { if (ob->mode == OB_MODE_PARTICLE_EDIT) - PE_create_current(scene, ob); + PE_create_current(bmain, scene, ob); } void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) @@ -330,6 +333,7 @@ typedef struct PEData { ViewContext vc; bglMats mats; + Main *bmain; Scene *scene; Object *ob; DerivedMesh *dm; @@ -364,9 +368,10 @@ static void PE_set_data(bContext *C, PEData *data) { memset(data, 0, sizeof(*data)); + data->bmain = CTX_data_main(C); data->scene= CTX_data_scene(C); data->ob= CTX_data_active_object(C); - data->edit= PE_get_current(data->scene, data->ob); + data->edit= PE_get_current(data->bmain, data->scene, data->ob); } static void PE_set_view3d_data(bContext *C, PEData *data) @@ -1128,9 +1133,9 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys) BLI_kdtree_balance(edit->emitter_field); } -static void PE_update_selection(Scene *scene, Object *ob, int useflag) +static void PE_update_selection(Main *bmain, Scene *scene, Object *ob, int useflag) { - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); HairKey *hkey; POINT_P; KEY_K; @@ -1235,12 +1240,12 @@ static void update_velocities(PTCacheEdit *edit) } } -void PE_update_object(Scene *scene, Object *ob, int useflag) +void PE_update_object(Main *bmain, 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 */ ParticleEditSettings *pset= PE_settings(scene); - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); POINT_P; if (!edit) @@ -1374,9 +1379,10 @@ static void select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in static int pe_select_all_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); POINT_P; KEY_K; int action = RNA_enum_get(op->ptr, "action"); @@ -1399,7 +1405,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op) } } - PE_update_selection(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1426,10 +1432,11 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { + Main *bmain = CTX_data_main(C); PEData data; Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); POINT_P; KEY_K; if (!PE_start_edit(edit)) @@ -1456,7 +1463,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(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1497,7 +1504,7 @@ static int select_roots_exec(bContext *C, wmOperator *op) data.select_action = action; foreach_point(&data, select_root); - PE_update_selection(data.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1562,7 +1569,7 @@ static int select_tips_exec(bContext *C, wmOperator *op) data.select_action = action; foreach_point(&data, select_tip); - PE_update_selection(data.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1600,8 +1607,6 @@ static int select_random_exec(bContext *C, wmOperator *op) { PEData data; int type; - Scene *scene; - Object *ob; /* used by LOOP_VISIBLE_POINTS, LOOP_VISIBLE_KEYS and LOOP_KEYS */ PTCacheEdit *edit; @@ -1619,9 +1624,7 @@ static int select_random_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); data.select_action = SEL_SELECT; - scene = CTX_data_scene(C); - ob = CTX_data_active_object(C); - edit = PE_get_current(scene, ob); + edit = PE_get_current(data.bmain, data.scene, data.ob); rng = BLI_rng_new_srandom(seed); @@ -1646,7 +1649,7 @@ static int select_random_exec(bContext *C, wmOperator *op) BLI_rng_free(rng); - PE_update_selection(data.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1690,7 +1693,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.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -1737,9 +1740,10 @@ void PE_deselect_all_visible(PTCacheEdit *edit) int PE_border_select(bContext *C, rcti *rect, bool select, bool extend) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); PEData data; if (!PE_start_edit(edit)) @@ -1754,7 +1758,7 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend) for_mouse_hit_keys(&data, select_key, 0); - PE_update_selection(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1764,9 +1768,10 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend) int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); PEData data; if (!PE_start_edit(edit)) @@ -1779,7 +1784,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(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1789,11 +1794,12 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool extend, bool select) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); ARegion *ar= CTX_wm_region(C); ParticleEditSettings *pset= PE_settings(scene); - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); POINT_P; KEY_K; @@ -1867,7 +1873,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool } } - PE_update_selection(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1877,9 +1883,10 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool static int hide_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Object *ob= CTX_data_active_object(C); Scene *scene= CTX_data_scene(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); POINT_P; KEY_K; if (RNA_enum_get(op->ptr, "unselected")) { @@ -1901,7 +1908,7 @@ static int hide_exec(bContext *C, wmOperator *op) } } - PE_update_selection(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -1929,9 +1936,10 @@ void PARTICLE_OT_hide(wmOperatorType *ot) static int reveal_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Object *ob= CTX_data_active_object(C); Scene *scene= CTX_data_scene(C); - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); const bool select = RNA_boolean_get(op->ptr, "select"); POINT_P; KEY_K; @@ -1946,7 +1954,7 @@ static int reveal_exec(bContext *C, wmOperator *op) } } - PE_update_selection(scene, ob, 1); + PE_update_selection(bmain, scene, ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob); return OPERATOR_FINISHED; @@ -2008,7 +2016,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.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -2070,7 +2078,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.scene, data.ob, 1); + PE_update_selection(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); return OPERATOR_FINISHED; @@ -2167,7 +2175,7 @@ static int rekey_exec(bContext *C, wmOperator *op) foreach_selected_point(&data, rekey_particle); recalc_lengths(data.edit); - PE_update_object(data.scene, data.ob, 1); + PE_update_object(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); return OPERATOR_FINISHED; @@ -2192,9 +2200,9 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) RNA_def_int(ot->srna, "keys_number", 2, 2, INT_MAX, "Number of Keys", "", 2, 100); } -static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float path_time) +static void rekey_particle_to_time(Main *bmain, Scene *scene, Object *ob, int pa_index, float path_time) { - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ParticleSystem *psys; ParticleSimulationData sim= {0}; ParticleData *pa; @@ -2498,7 +2506,7 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op)) foreach_point(&data, subdivide_particle); recalc_lengths(data.edit); - PE_update_object(data.scene, data.ob, 1); + PE_update_object(data.bmain, data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); return OPERATOR_FINISHED; @@ -2523,9 +2531,10 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) static int remove_doubles_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd; KDTree *tree; @@ -2615,10 +2624,11 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) static int weight_set_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); ParticleEditSettings *pset= PE_settings(scene); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit->psys; POINT_P; KEY_K; @@ -2772,11 +2782,11 @@ void PARTICLE_OT_delete(wmOperatorType *ot) /*************************** mirror operator **************************/ -static void PE_mirror_x(Scene *scene, Object *ob, int tagged) +static void PE_mirror_x(Main *bmain, Scene *scene, Object *ob, int tagged) { Mesh *me= (Mesh *)(ob->data); ParticleSystemModifierData *psmd; - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit->psys; ParticleData *pa, *newpa, *new_pars; PTCacheEditPoint *newpoint, *new_points; @@ -2922,11 +2932,12 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); - PE_mirror_x(scene, ob, 0); + PE_mirror_x(bmain, scene, ob, 0); update_world_cos(ob, edit); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); @@ -3063,7 +3074,7 @@ static void brush_cut(PEData *data, int pa_index) edit->points[pa_index].flag |= PEP_TAG; } else { - rekey_particle_to_time(data->scene, ob, pa_index, cut_time); + rekey_particle_to_time(data->bmain, data->scene, ob, pa_index, cut_time); edit->points[pa_index].flag |= PEP_EDIT_RECALC; } } @@ -3705,10 +3716,11 @@ typedef struct BrushEdit { static int brush_edit_init(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); ParticleEditSettings *pset= PE_settings(scene); - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; float min[3], max[3]; @@ -3718,7 +3730,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) /* set the 'distance factor' for grabbing (used in comb etc) */ INIT_MINMAX(min, max); - PE_minmax(scene, min, max); + PE_minmax(bmain, scene, min, max); mid_v3_v3v3(min, min, max); bedit= MEM_callocN(sizeof(BrushEdit), "BrushEdit"); @@ -3739,6 +3751,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { + Main *bmain = CTX_data_main(C); BrushEdit *bedit= op->customdata; Scene *scene= bedit->scene; Object *ob= bedit->ob; @@ -3931,14 +3944,14 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) { if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) - PE_mirror_x(scene, ob, 1); + PE_mirror_x(bmain, scene, ob, 1); update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else - PE_update_object(scene, ob, 1); + PE_update_object(bmain, scene, ob, 1); } if (edit->psys) { @@ -4153,7 +4166,7 @@ static void shape_cut(PEData *data, int pa_index) edit->points[pa_index].flag |= PEP_TAG; } else { - rekey_particle_to_time(data->scene, ob, pa_index, cut_time); + rekey_particle_to_time(data->bmain, data->scene, ob, pa_index, cut_time); edit->points[pa_index].flag |= PEP_EDIT_RECALC; } } @@ -4161,10 +4174,11 @@ static void shape_cut(PEData *data, int pa_index) static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); ParticleEditSettings *pset = PE_settings(scene); - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); Object *shapeob = pset->shape_object; int selected = count_selected_keys(scene, edit); int lock_root = pset->flag & PE_LOCK_FIRST; @@ -4200,7 +4214,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else - PE_update_object(scene, ob, 1); + PE_update_object(bmain, scene, ob, 1); if (edit->psys) { WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); @@ -4235,10 +4249,10 @@ void PARTICLE_OT_shape_cut(wmOperatorType *ot) /************************ utilities ******************************/ -int PE_minmax(Scene *scene, float min[3], float max[3]) +int PE_minmax(Main *bmain, Scene *scene, float min[3], float max[3]) { Object *ob= OBACT; - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit= PE_get_current(bmain, scene, ob); ParticleSystem *psys; ParticleSystemModifierData *psmd = NULL; POINT_P; KEY_K; @@ -4275,7 +4289,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) /************************ particle edit toggle operator ************************/ /* initialize needed data for bake edit */ -void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys) +void PE_create_particle_edit(Main *bmain, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys) { PTCacheEdit *edit; ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL; @@ -4376,7 +4390,7 @@ void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, Partic recalc_lengths(edit); if (psys && !cache) recalc_emitter_field(ob, psys); - PE_update_object(scene, ob, 1); + PE_update_object(bmain, scene, ob, 1); } } @@ -4398,6 +4412,7 @@ static int particle_edit_toggle_poll(bContext *C) static int particle_edit_toggle_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_PARTICLE_EDIT; @@ -4412,7 +4427,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) if (!is_mode_set) { PTCacheEdit *edit; ob->mode |= mode_flag; - edit= PE_create_current(scene, ob); + edit= PE_create_current(bmain, 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 */ @@ -4578,16 +4593,17 @@ static void scale_points_to_length(PTCacheEdit *edit, float length) static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); float average_length = calculate_average_length(edit); if (average_length == 0.0f) { return OPERATOR_CANCELLED; } scale_points_to_length(edit, average_length); - PE_update_object(scene, ob, 1); + PE_update_object(bmain, 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_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index ef0a2711fdd..3d17b1a20c1 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -44,10 +44,11 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_context.h" #include "BKE_undo_system.h" #include "ED_object.h" @@ -228,24 +229,27 @@ typedef struct ParticleUndoStep { static bool particle_undosys_poll(struct bContext *C) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = OBACT; - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); return (edit != NULL); } static bool particle_undosys_step_encode(struct bContext *C, UndoStep *us_p) { + Main *bmain = CTX_data_main(C); ParticleUndoStep *us = (ParticleUndoStep *)us_p; us->scene_ref.ptr = CTX_data_scene(C); us->object_ref.ptr = us->scene_ref.ptr->basact->object; - PTCacheEdit *edit = PE_get_current(us->scene_ref.ptr, us->object_ref.ptr); + PTCacheEdit *edit = PE_get_current(bmain, us->scene_ref.ptr, us->object_ref.ptr); undoptcache_from_editcache(&us->data, edit); return true; } static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) { + Main *bmain = CTX_data_main(C); /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_PARTICLE_EDIT); BLI_assert(particle_undosys_poll(C)); @@ -253,7 +257,7 @@ static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int ParticleUndoStep *us = (ParticleUndoStep *)us_p; Scene *scene = us->scene_ref.ptr; Object *ob = us->object_ref.ptr; - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); if (edit) { undoptcache_to_editcache(&us->data, edit); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 66c62d47340..873ea196c35 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -544,7 +544,7 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot) /************************ connect/disconnect hair operators *********************/ -static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) +static void disconnect_hair(Main *bmain, Scene *scene, Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); ParticleEditSettings *pset= PE_settings(scene); @@ -590,11 +590,12 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) pset->brushtype = PE_BRUSH_NONE; - PE_update_object(scene, ob, 0); + PE_update_object(bmain, scene, ob, 0); } static int disconnect_hair_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= ED_object_context(C); ParticleSystem *psys= NULL; @@ -605,12 +606,12 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op) if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - disconnect_hair(scene, ob, psys); + disconnect_hair(bmain, scene, ob, psys); } } else { psys = psys_get_current(ob); - disconnect_hair(scene, ob, psys); + disconnect_hair(bmain, scene, ob, psys); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -636,7 +637,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) /* from/to_world_space : whether from/to particles are in world or hair space * from/to_mat : additional transform for from/to particles (e.g. for using object space copying) */ -static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, +static bool remap_hair_emitter(Main *bmain, 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) { @@ -822,19 +823,20 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, psys_free_path_cache(target_psys, target_edit); - PE_update_object(scene, target_ob, 0); + PE_update_object(bmain, scene, target_ob, 0); return true; } -static bool connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) +static bool connect_hair(Main *bmain, Scene *scene, Object *ob, ParticleSystem *psys) { bool ok; if (!psys) return false; - ok = remap_hair_emitter(scene, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); + ok = remap_hair_emitter(bmain, scene, ob, psys, ob, psys, psys->edit, + ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); psys->flag &= ~PSYS_GLOBAL_HAIR; return ok; @@ -842,6 +844,7 @@ static bool connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) static int connect_hair_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= ED_object_context(C); ParticleSystem *psys= NULL; @@ -853,12 +856,12 @@ static int connect_hair_exec(bContext *C, wmOperator *op) if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - any_connected |= connect_hair(scene, ob, psys); + any_connected |= connect_hair(bmain, scene, ob, psys); } } else { psys = psys_get_current(ob); - any_connected |= connect_hair(scene, ob, psys); + any_connected |= connect_hair(bmain, scene, ob, psys); } if (!any_connected) { @@ -894,7 +897,7 @@ typedef enum eCopyParticlesSpace { PAR_COPY_SPACE_WORLD = 1, } eCopyParticlesSpace; -static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from) +static void copy_particle_edit(Main *bmain, Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from) { PTCacheEdit *edit_from = psys_from->edit, *edit; ParticleData *pa; @@ -941,7 +944,7 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P recalc_lengths(edit); recalc_emitter_field(ob, psys); - PE_update_object(scene, ob, true); + PE_update_object(bmain, scene, ob, true); } static void remove_particle_systems_from_object(Object *ob_to) @@ -1051,7 +1054,7 @@ static bool copy_particle_systems_to_object(Main *bmain, DM_ensure_tessface(psmd->dm_final); if (psys_from->edit) - copy_particle_edit(scene, ob_to, psys, psys_from); + copy_particle_edit(bmain, scene, ob_to, psys, psys_from); if (duplicate_settings) { id_us_min(&psys->part->id); @@ -1085,7 +1088,9 @@ static bool copy_particle_systems_to_object(Main *bmain, break; } if (ob_from != ob_to) { - remap_hair_emitter(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); + remap_hair_emitter( + bmain, 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); } /* tag for recalc */ diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index f3f3697caaa..3f958f363b6 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -68,7 +68,8 @@ void PARTICLE_OT_edited_clear(struct wmOperatorType *ot); void PARTICLE_OT_unify_length(struct wmOperatorType *ot); -void PE_create_particle_edit(struct Scene *scene, struct Object *ob, struct PointCache *cache, struct ParticleSystem *psys); +void PE_create_particle_edit( + struct Main *bmain, 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); void update_world_cos(struct Object *ob, struct PTCacheEdit *edit); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index fc2f7e40645..53aa14d3a56 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -176,7 +176,7 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) PointCache *cache = ptr.data; ListBase pidlist; - BKE_ptcache_ids_from_object(&pidlist, ob, baker->scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(baker->bmain, &pidlist, ob, baker->scene, MAX_DUPLI_RECUR); for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { @@ -253,13 +253,14 @@ static void ptcache_bake_cancel(bContext *C, wmOperator *op) static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Base *base; PTCacheID *pid; ListBase pidlist; - for (base=scene->base.first; base; base= base->next) { - BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); + for (base = scene->base.first; base; base = base->next) { + BKE_ptcache_ids_from_object(bmain, &pidlist, base->object, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { ptcache_free_bake(pid->cache); @@ -383,6 +384,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); Object *ob= ptr.id.data; @@ -390,7 +392,7 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { if (pid->cache == cache) { @@ -410,6 +412,7 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) } static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); Scene *scene= CTX_data_scene(C); Object *ob= ptr.id.data; @@ -417,7 +420,7 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { if (pid->cache == cache) { diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 03045364e5b..97daed53e24 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -97,7 +97,7 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); } -static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) +static void time_draw_cache(Main *bmain, SpaceTime *stime, Object *ob, Scene *scene) { PTCacheID *pid; ListBase pidlist; @@ -108,7 +108,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; - BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, 0); /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ @@ -569,6 +569,7 @@ static void time_main_region_init(wmWindowManager *wm, ARegion *ar) static void time_main_region_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SpaceTime *stime = CTX_wm_space_time(C); Object *obact = CTX_data_active_object(C); @@ -610,7 +611,7 @@ static void time_main_region_draw(const bContext *C, ARegion *ar) ED_markers_draw(C, 0); /* caches */ - time_draw_cache(stime, obact, scene); + time_draw_cache(bmain, stime, obact, scene); /* callback */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b3c4f988f19..c10f8f0ce16 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5726,10 +5726,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } } -static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit) +static void draw_update_ptcache_edit(Main *bmain, Scene *scene, Object *ob, PTCacheEdit *edit) { if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED) - PE_update_object(scene, ob, 0); + PE_update_object(bmain, scene, ob, 0); /* create path and child path cache if it doesn't exist already */ if (edit->pathcache == NULL) @@ -7818,9 +7818,9 @@ void draw_object(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base for (psys = ob->particlesystem.first; psys; psys = psys->next) { /* run this so that possible child particles get cached */ if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { - PTCacheEdit *edit = PE_create_current(scene, ob); + PTCacheEdit *edit = PE_create_current(bmain, scene, ob); if (edit && edit->psys == psys) - draw_update_ptcache_edit(scene, ob, edit); + draw_update_ptcache_edit(bmain, scene, ob, edit); } draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag); @@ -7840,10 +7840,10 @@ void draw_object(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base { if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { - PTCacheEdit *edit = PE_create_current(scene, ob); + PTCacheEdit *edit = PE_create_current(bmain, scene, ob); if (edit) { glLoadMatrixf(rv3d->viewmat); - draw_update_ptcache_edit(scene, ob, edit); + draw_update_ptcache_edit(bmain, scene, ob, edit); draw_ptcache_edit(scene, v3d, edit); glMultMatrixf(ob->obmat); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 86b121ee9a5..54d56dff903 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2842,7 +2842,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) ok = paintface_minmax(ob, min, max); } else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { - ok = PE_minmax(scene, min, max); + ok = PE_minmax(bmain, scene, min, max); } else if (ob && (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 767ac17f1bf..2836ed0699d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1908,9 +1908,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) { TransData *td = NULL; TransDataExtension *tx; + Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); ParticleEditSettings *pset = PE_settings(t->scene); - PTCacheEdit *edit = PE_get_current(t->scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, t->scene, ob); ParticleSystem *psys = NULL; ParticleSystemModifierData *psmd = NULL; PTCacheEditPoint *point; @@ -2024,9 +2025,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) void flushTransParticles(TransInfo *t) { + Main *bmain = CTX_data_main(t->context); Scene *scene = t->scene; Object *ob = OBACT; - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd = NULL; PTCacheEditPoint *point; @@ -2065,7 +2067,7 @@ void flushTransParticles(TransInfo *t) point->flag |= PEP_EDIT_RECALC; } - PE_update_object(scene, OBACT, 1); + PE_update_object(bmain, scene, OBACT, 1); } /* ********************* mesh ****************** */ @@ -6567,7 +6569,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if ((t->scene->basact) && (ob = t->scene->basact->object) && (ob->mode & OB_MODE_PARTICLE_EDIT) && - PE_get_current(t->scene, ob)) + PE_get_current(bmain, t->scene, ob)) { /* do nothing */ } @@ -6589,7 +6591,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) continue; /* flag object caches as outdated */ - BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, t->scene, MAX_DUPLI_RECUR); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ pid->cache->flag |= PTCACHE_OUTDATED; @@ -8148,6 +8150,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) void createTransData(bContext *C, TransInfo *t) { + Main *bmain = CTX_data_main(C); Scene *scene = t->scene; Object *ob = OBACT; @@ -8324,7 +8327,7 @@ void createTransData(bContext *C, TransInfo *t) } } - else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(bmain, scene, ob))) { createTransParticleVerts(C, t); t->flag |= T_POINTS; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index fec98c77c19..477e1abf80f 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -75,6 +75,7 @@ #include "BKE_fcurve.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_context.h" #include "BKE_paint.h" @@ -734,6 +735,7 @@ static void recalcData_spaceclip(TransInfo *t) /* helper for recalcData() - for object transforms, typically in the 3D view */ static void recalcData_objects(TransInfo *t) { + Main *bmain = CTX_data_main(t->context); Base *base = t->scene->basact; if (t->obedit) { @@ -921,7 +923,7 @@ static void recalcData_objects(TransInfo *t) else BKE_pose_where_is(t->scene, ob); } - else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { + else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(bmain, t->scene, base->object)) { if (t->state != TRANS_CANCEL) { applyProject(t); } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 5997777f635..ca133de1247 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -54,6 +54,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_editmesh.h" @@ -263,6 +264,7 @@ bool gimbal_axis(Object *ob, float gmat[3][3]) /* returns total items selected */ static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbounds) { + Main *bmain = CTX_data_main(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -562,7 +564,7 @@ static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbo /* pass */ } else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); PTCacheEditPoint *point; PTCacheEditKey *ek; int k; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 107b3f6ad57..bd2d8e98bb0 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -752,11 +752,11 @@ static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int val psys_set_current_num(ob, value); } -static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_Object_particle_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - PE_current_changed(scene, ob); + PE_current_changed(bmain, scene, ob); } /* rotation - axis-angle */ diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 2b0740bff6f..294597d957e 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -95,13 +95,14 @@ static const EnumPropertyItem empty_vortex_shape_items[] = { #include "DNA_texture_types.h" #include "BKE_context.h" +#include "BKE_depsgraph.h" +#include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" -#include "BKE_depsgraph.h" #include "ED_object.h" -static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_change(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; @@ -113,7 +114,7 @@ static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR cache->flag |= PTCACHE_OUTDATED; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -132,7 +133,7 @@ static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR BLI_freelistN(&pidlist); } -static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_toggle_disk_cache(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; @@ -142,7 +143,7 @@ static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene if (!ob) return; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) @@ -158,7 +159,7 @@ static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene BLI_freelistN(&pidlist); } -static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_idname_change(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; @@ -171,7 +172,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P /* TODO: check for proper characters */ - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); if (cache->flag & PTCACHE_EXTERNAL) { for (pid = pidlist.first; pid; pid = pid->next) { @@ -239,7 +240,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); *min = 0; *max = 0; @@ -262,7 +263,7 @@ static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) ListBase pidlist; int num = 0; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { @@ -283,7 +284,7 @@ static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int v PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { @@ -306,7 +307,7 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, *min = 1; *max = 20; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 2bc188212fe..11610c35b34 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -40,8 +40,9 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "BKE_paint.h" +#include "BKE_main.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "ED_image.h" @@ -103,10 +104,11 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #include "MEM_guardedalloc.h" #include "BKE_context.h" +#include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" -#include "BKE_pointcache.h" +#include "BKE_global.h" #include "BKE_particle.h" -#include "BKE_depsgraph.h" +#include "BKE_pointcache.h" #include "BKE_pbvh.h" #include "GPU_buffers.h" @@ -152,10 +154,10 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } -static void rna_ParticleEdit_redo(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_redo(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = (scene->basact) ? scene->basact->object : NULL; - PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); if (!edit) return; @@ -190,7 +192,8 @@ static const EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerR Scene *scene = CTX_data_scene(C); Object *ob = (scene->basact) ? scene->basact->object : NULL; #if 0 - PTCacheEdit *edit = PE_get_current(scene, ob); + Main *bmain = CTX_data_main(C); + PTCacheEdit *edit = PE_get_current(bmain, scene, ob); ParticleSystem *psys = edit ? edit->psys : NULL; #else /* use this rather than PE_get_current() - because the editing cache is @@ -215,14 +218,14 @@ static int rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; - return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object)); + return (pset->object && pset->scene && PE_get_current(G.main, pset->scene, pset->object)); } static int rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; if (pset->scene) { - PTCacheEdit *edit = PE_get_current(pset->scene, pset->object); + PTCacheEdit *edit = PE_get_current(G.main, pset->scene, pset->object); return (edit && edit->psys); } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index d3a6373f29c..c04443b6251 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -417,8 +417,8 @@ void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *name) RET char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry) RET_NULL void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) RET_NONE -struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob) RET_NULL -void PE_current_changed(struct Scene *scene, struct Object *ob) RET_NONE +struct PTCacheEdit *PE_get_current(struct Main *bmain, struct Scene *scene, struct Object *ob) RET_NULL +void PE_current_changed(struct Main *bmain, struct Scene *scene, struct Object *ob) RET_NONE /* rna keymap */ struct wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap) RET_NULL |