Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Rood <dev@lucarood.com>2017-07-21 12:53:13 +0300
committerLuca Rood <dev@lucarood.com>2017-07-21 15:47:26 +0300
commit1c4c288727214fa0588d66556a1cdf71755d70b4 (patch)
tree1433952be7e88cc7d09e8563831995290e3013ce /source/blender/editors/physics
parent9edb7e49d7e5e69385f3a0434c568c79fad88cd8 (diff)
Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx was not available there. This should be resolved once DerivedMesh is replaced.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c10
-rw-r--r--source/blender/editors/physics/particle_edit.c150
-rw-r--r--source/blender/editors/physics/particle_object.c43
-rw-r--r--source/blender/editors/physics/physics_fluid.c22
4 files changed, 134 insertions, 91 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index cd07b57577b..1f0ee6862d2 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -294,6 +294,8 @@ typedef struct DynamicPaintBakeJob {
DynamicPaintSurface *surface;
DynamicPaintCanvasSettings *canvas;
+ EvaluationContext *eval_ctx;
+
int success;
double start;
} DynamicPaintBakeJob;
@@ -313,6 +315,8 @@ 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);
@@ -387,7 +391,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
/* calculate a frame */
scene->r.cfra = (int)frame;
ED_update_for_newframe(job->bmain, scene, 1);
- if (!dynamicPaint_calculateFrame(surface, scene, job->scene_layer, cObject, frame)) {
+ if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) {
job->success = 0;
return;
}
@@ -456,6 +460,9 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext");
+
+ CTX_data_eval_ctx(C, eval_ctx);
DynamicPaintSurface *surface;
@@ -487,6 +494,7 @@ 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 fb3cfdc86b2..ca454cca576 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -86,7 +86,7 @@
#include "physics_intern.h"
-void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
+void PE_create_particle_edit(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
void PTCacheUndo_clear(PTCacheEdit *edit);
void recalc_lengths(PTCacheEdit *edit);
void recalc_emitter_field(Object *ob, ParticleSystem *psys);
@@ -216,7 +216,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, SceneLayer *sl, Object *ob, int create)
+static PTCacheEdit *pe_get_current(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, int create)
{
ParticleEditSettings *pset= PE_settings(scene);
PTCacheEdit *edit = NULL;
@@ -256,18 +256,18 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
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, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(C, scene, sl, ob, pid->cache, NULL);
edit = pid->cache->edit;
}
else {
if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE)
- PE_create_particle_edit(scene, sl, ob, NULL, psys);
+ PE_create_particle_edit(C, scene, sl, ob, NULL, psys);
edit = psys->edit;
}
}
else {
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
- PE_create_particle_edit(scene, sl, ob, pid->cache, psys);
+ PE_create_particle_edit(C, scene, sl, ob, pid->cache, psys);
edit = pid->cache->edit;
}
@@ -278,7 +278,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
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, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(C, scene, sl, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -287,7 +287,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
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, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(C, scene, sl, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -304,18 +304,18 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
PTCacheEdit *PE_get_current(Scene *scene, SceneLayer *sl, Object *ob)
{
- return pe_get_current(scene, sl, ob, 0);
+ return pe_get_current(NULL, scene, sl, ob, 0);
}
-PTCacheEdit *PE_create_current(Scene *scene, Object *ob)
+PTCacheEdit *PE_create_current(const bContext *C, Scene *scene, Object *ob)
{
- return pe_get_current(scene, NULL, ob, 1);
+ return pe_get_current(C, scene, NULL, ob, 1);
}
-void PE_current_changed(Scene *scene, Object *ob)
+void PE_current_changed(const bContext *C, Scene *scene, Object *ob)
{
if (ob->mode == OB_MODE_PARTICLE_EDIT)
- PE_create_current(scene, ob);
+ PE_create_current(C, scene, ob);
}
void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
@@ -358,6 +358,7 @@ static int pe_x_mirror(Object *ob)
typedef struct PEData {
ViewContext vc;
+ const bContext *context;
Scene *scene;
SceneLayer *scene_layer;
Object *ob;
@@ -393,10 +394,10 @@ static void PE_set_data(bContext *C, PEData *data)
{
memset(data, 0, sizeof(*data));
- data->scene= CTX_data_scene(C);
+ data->scene = CTX_data_scene(C);
data->scene_layer = CTX_data_scene_layer(C);
- data->ob= CTX_data_active_object(C);
- data->edit= PE_get_current(data->scene, data->scene_layer, data->ob);
+ data->ob = CTX_data_active_object(C);
+ data->edit = PE_get_current(data->scene, data->scene_layer, data->ob);
}
static void PE_set_view3d_data(bContext *C, PEData *data)
@@ -410,7 +411,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->vc);
+ ED_view3d_backbuf_validate(C, &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; */
@@ -1156,12 +1157,15 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys)
BLI_kdtree_balance(edit->emitter_field);
}
-static void PE_update_selection(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
+static void PE_update_selection(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, int useflag)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, ob);
+ PTCacheEdit *edit = PE_get_current(scene, sl, ob);
HairKey *hkey;
+ EvaluationContext eval_ctx;
POINT_P; KEY_K;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* flag all particles to be updated if not using flag */
if (!useflag)
LOOP_POINTS
@@ -1177,7 +1181,7 @@ static void PE_update_selection(Scene *scene, SceneLayer *sl, Object *ob, int us
}
}
- psys_cache_edit_paths(scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(&eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
@@ -1263,17 +1267,20 @@ static void update_velocities(PTCacheEdit *edit)
}
}
-void PE_update_object(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
+void PE_update_object(const bContext *C, Scene *scene, SceneLayer *sl, 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, sl, ob);
+ EvaluationContext eval_ctx;
POINT_P;
if (!edit)
return;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* flag all particles to be updated if not using flag */
if (!useflag)
LOOP_POINTS {
@@ -1293,7 +1300,7 @@ void PE_update_object(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
- psys_cache_edit_paths(scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(&eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
LOOP_POINTS {
@@ -1428,7 +1435,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1461,7 +1468,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
Object *ob= CTX_data_active_object(C);
PTCacheEdit *edit= PE_get_current(scene, sl, ob);
POINT_P; KEY_K;
-
+
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
@@ -1486,7 +1493,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, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1527,7 +1534,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.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1592,7 +1599,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.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1678,7 +1685,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1722,7 +1729,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.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1787,7 +1794,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, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1813,7 +1820,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, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1902,7 +1909,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1937,7 +1944,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1981,7 +1988,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -2040,7 +2047,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.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2102,7 +2109,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.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2135,12 +2142,15 @@ 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;
- sim.scene= data->scene;
- sim.ob= data->ob;
- sim.psys= edit->psys;
+ CTX_data_eval_ctx(data->context, &eval_ctx);
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = data->scene;
+ sim.ob = data->ob;
+ sim.psys = edit->psys;
pa->flag |= PARS_REKEY;
@@ -2199,7 +2209,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.scene_layer, data.ob, 1);
+ PE_update_object(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2224,24 +2234,28 @@ 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, SceneLayer *sl, Object *ob, int pa_index, float path_time)
+static void rekey_particle_to_time(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, int pa_index, float path_time)
{
PTCacheEdit *edit= PE_get_current(scene, sl, ob);
ParticleSystem *psys;
- ParticleSimulationData sim= {0};
+ ParticleSimulationData sim = {0};
ParticleData *pa;
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.scene= scene;
- sim.ob= ob;
- sim.psys= psys;
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = scene;
+ sim.ob = ob;
+ sim.psys = psys;
pa= psys->particles + pa_index;
@@ -2451,14 +2465,17 @@ 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;
- sim.scene= data->scene;
- sim.ob= data->ob;
- sim.psys= edit->psys;
+ CTX_data_eval_ctx(data->context, &eval_ctx);
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = data->scene;
+ sim.ob = data->ob;
+ sim.psys = edit->psys;
for (k=0, ekey=point->keys; k<pa->totkey-1; k++, ekey++) {
if (ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT)
@@ -2530,7 +2547,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.scene_layer, data.ob, 1);
+ PE_update_object(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2813,7 +2830,7 @@ static void PE_mirror_x(Scene *scene, SceneLayer *sl, Object *ob, int tagged)
{
Mesh *me= (Mesh *)(ob->data);
ParticleSystemModifierData *psmd;
- PTCacheEdit *edit= PE_get_current(scene, sl, ob);
+ PTCacheEdit *edit = PE_get_current(scene, sl, ob);
ParticleSystem *psys = edit->psys;
ParticleData *pa, *newpa, *new_pars;
PTCacheEditPoint *newpoint, *new_points;
@@ -3101,7 +3118,7 @@ static void brush_cut(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
else {
- rekey_particle_to_time(data->scene, data->scene_layer, ob, pa_index, cut_time);
+ rekey_particle_to_time(data->context, data->scene, data->scene_layer, ob, pa_index, cut_time);
edit->points[pa_index].flag |= PEP_EDIT_RECALC;
}
}
@@ -3349,25 +3366,28 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons
}
/* check intersection with a derivedmesh */
-static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
+static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, DerivedMesh *dm,
float *vert_cos,
const float co1[3], const float co2[3],
float *min_d, int *min_face, float *min_w,
float *face_minmax, float *pa_minmax,
float radius, float *ipoint)
{
+ EvaluationContext eval_ctx;
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(scene, ob, 0);
+ dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0);
if (dm == NULL)
- dm=mesh_get_derived_deform(scene, ob, 0);
+ dm = mesh_get_derived_deform(&eval_ctx, scene, ob, 0);
psys_enable_all(ob);
@@ -3480,8 +3500,9 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
return intersect;
}
-static int brush_add(PEData *data, short number)
+static int brush_add(const bContext *C, PEData *data, short number)
{
+ EvaluationContext eval_ctx;
Scene *scene= data->scene;
Object *ob= data->ob;
DerivedMesh *dm;
@@ -3509,6 +3530,9 @@ static int brush_add(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.scene= scene;
sim.ob= ob;
sim.psys= psys;
@@ -3549,7 +3573,7 @@ static int brush_add(PEData *data, short number)
min_d=2.0;
/* warning, returns the derived mesh face */
- if (particle_intersect_dm(scene, ob, dm, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
+ if (particle_intersect_dm(C, scene, ob, dm, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
if (psys->part->use_modifier_stack && !psmd->dm_final->deformedOnly) {
add_pars[n].num = add_pars[n].num_dmcache;
add_pars[n].num_dmcache = DMCACHE_ISCHILD;
@@ -3923,7 +3947,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (edit->psys && edit->psys->part->from==PART_FROM_FACE) {
data.mval= mval;
- added= brush_add(&data, brush->count);
+ added= brush_add(C, &data, brush->count);
if (pset->flag & PE_KEEP_LENGTHS)
recalc_lengths(edit);
@@ -3980,7 +4004,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(scene, sl, ob, 1);
+ PE_update_object(C, scene, sl, ob, 1);
}
if (edit->psys) {
@@ -4193,7 +4217,7 @@ static void shape_cut(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
else {
- rekey_particle_to_time(data->scene, data->scene_layer, ob, pa_index, cut_time);
+ rekey_particle_to_time(data->context, data->scene, data->scene_layer, ob, pa_index, cut_time);
edit->points[pa_index].flag |= PEP_EDIT_RECALC;
}
}
@@ -4241,7 +4265,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else
- PE_update_object(scene, sl, ob, 1);
+ PE_update_object(C, scene, sl, ob, 1);
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
@@ -4603,7 +4627,7 @@ int PE_minmax(Scene *scene, SceneLayer *sl, float min[3], float max[3])
/************************ particle edit toggle operator ************************/
/* initialize needed data for bake edit */
-void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys)
+void PE_create_particle_edit(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys)
{
PTCacheEdit *edit;
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL;
@@ -4704,7 +4728,7 @@ void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCach
recalc_lengths(edit);
if (psys && !cache)
recalc_emitter_field(ob, psys);
- PE_update_object(scene, sl, ob, 1);
+ PE_update_object(C, scene, sl, ob, 1);
PTCacheUndo_clear(edit);
PE_undo_push(scene, sl, "Original");
@@ -4746,7 +4770,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(C, 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 */
@@ -4922,7 +4946,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
}
scale_points_to_length(edit, average_length);
- PE_update_object(scene, sl, ob, 1);
+ PE_update_object(C, scene, sl, 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 cd7bb8640b5..8a08be75421 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -71,7 +71,7 @@
#include "physics_intern.h"
-extern void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
+extern void PE_create_particle_edit(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
extern void PTCacheUndo_clear(PTCacheEdit *edit);
extern void recalc_lengths(PTCacheEdit *edit);
extern void recalc_emitter_field(Object *ob, ParticleSystem *psys);
@@ -568,7 +568,7 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
/************************ connect/disconnect hair operators *********************/
-static void disconnect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
+static void disconnect_hair(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
ParticleEditSettings *pset= PE_settings(scene);
@@ -614,7 +614,7 @@ static void disconnect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSy
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF))
pset->brushtype = PE_BRUSH_NONE;
- PE_update_object(scene, sl, ob, 0);
+ PE_update_object(C, scene, sl, ob, 0);
}
static int disconnect_hair_exec(bContext *C, wmOperator *op)
@@ -630,12 +630,12 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- disconnect_hair(scene, sl, ob, psys);
+ disconnect_hair(C, scene, sl, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- disconnect_hair(scene, sl, ob, psys);
+ disconnect_hair(C, scene, sl, ob, psys);
}
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -661,7 +661,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, SceneLayer *sl, Object *ob, ParticleSystem *psys,
+static bool remap_hair_emitter(const bContext *C, Scene *scene, SceneLayer *sl, 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)
{
@@ -847,19 +847,19 @@ static bool remap_hair_emitter(Scene *scene, SceneLayer *sl, Object *ob, Particl
psys_free_path_cache(target_psys, target_edit);
- PE_update_object(scene, sl, target_ob, 0);
+ PE_update_object(C, scene, sl, target_ob, 0);
return true;
}
-static bool connect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
+static bool connect_hair(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
{
bool ok;
if (!psys)
return false;
- ok = remap_hair_emitter(scene, sl, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
+ ok = remap_hair_emitter(C, scene, sl, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
psys->flag &= ~PSYS_GLOBAL_HAIR;
return ok;
@@ -879,12 +879,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, sl, ob, psys);
+ any_connected |= connect_hair(C, scene, sl, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- any_connected |= connect_hair(scene, sl, ob, psys);
+ any_connected |= connect_hair(C, scene, sl, ob, psys);
}
if (!any_connected) {
@@ -920,7 +920,7 @@ typedef enum eCopyParticlesSpace {
PAR_COPY_SPACE_WORLD = 1,
} eCopyParticlesSpace;
-static void copy_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
+static void copy_particle_edit(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
{
PTCacheEdit *edit_from = psys_from->edit, *edit;
ParticleData *pa;
@@ -970,7 +970,7 @@ static void copy_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, Particl
recalc_lengths(edit);
recalc_emitter_field(ob, psys);
- PE_update_object(scene, sl, ob, true);
+ PE_update_object(C, scene, sl, ob, true);
PTCacheUndo_clear(edit);
PE_undo_push(scene, sl, "Original");
@@ -1001,7 +1001,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
}
/* single_psys_from is optional, if NULL all psys of ob_from are copied */
-static bool copy_particle_systems_to_object(Main *bmain,
+static bool copy_particle_systems_to_object(const bContext *C,
Scene *scene,
SceneLayer *sl,
Object *ob_from,
@@ -1010,6 +1010,8 @@ static bool copy_particle_systems_to_object(Main *bmain,
int space,
bool duplicate_settings)
{
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
@@ -1017,6 +1019,8 @@ static bool copy_particle_systems_to_object(Main *bmain,
CustomDataMask cdmask;
int i, totpsys;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (ob_to->type != OB_MESH)
return false;
if (!ob_to->data || ID_IS_LINKED_DATABLOCK(ob_to->data))
@@ -1055,7 +1059,7 @@ static bool copy_particle_systems_to_object(Main *bmain,
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(scene, ob_to, cdmask);
+ final_dm = mesh_get_derived_final(&eval_ctx, scene, ob_to, cdmask);
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST;
@@ -1084,7 +1088,7 @@ static bool copy_particle_systems_to_object(Main *bmain,
DM_ensure_tessface(psmd->dm_final);
if (psys_from->edit)
- copy_particle_edit(scene, sl, ob_to, psys, psys_from);
+ copy_particle_edit(C, scene, sl, ob_to, psys, psys_from);
if (duplicate_settings) {
id_us_min(&psys->part->id);
@@ -1118,7 +1122,7 @@ static bool copy_particle_systems_to_object(Main *bmain,
break;
}
if (ob_from != ob_to) {
- remap_hair_emitter(scene, sl, 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(C, scene, sl, 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 */
@@ -1151,7 +1155,6 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
const int space = RNA_enum_get(op->ptr, "space");
const bool remove_target_particles = RNA_boolean_get(op->ptr, "remove_target_particles");
const bool use_active = RNA_boolean_get(op->ptr, "use_active");
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *ob_from = ED_object_active_context(C);
@@ -1168,7 +1171,7 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
remove_particle_systems_from_object(ob_to);
changed = true;
}
- if (copy_particle_systems_to_object(bmain, scene, sl, ob_from, psys_from, ob_to, space, false))
+ if (copy_particle_systems_to_object(C, scene, sl, ob_from, psys_from, ob_to, space, false))
changed = true;
else
fail++;
@@ -1229,7 +1232,7 @@ static int duplicate_particle_systems_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
- copy_particle_systems_to_object(CTX_data_main(C), scene, CTX_data_scene_layer(C), ob, psys, ob,
+ copy_particle_systems_to_object(C, scene, CTX_data_scene_layer(C), ob, psys, ob,
PAR_COPY_SPACE_OBJECT, duplicate_settings);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 6e62dbabbca..9cd571c68cf 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -55,6 +55,8 @@
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+
#include "LBM_fluidsim.h"
#include "ED_screen.h"
@@ -244,7 +246,7 @@ static void set_channel(float *channel, float time, float *value, int i, int siz
}
}
-static void set_vertex_channel(float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
+static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
{
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -257,7 +259,7 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene,
if (channel == NULL)
return;
- initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
+ initElbeemMesh(eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
/* don't allow mesh to change number of verts in anim sequence */
if (numVerts != fobj->numVerts) {
@@ -330,10 +332,13 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(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);
@@ -374,7 +379,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(scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(&eval_ctx, 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);
@@ -462,15 +467,18 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
}
if (fluid_is_animated_mesh(fluidmd->fss)) {
- set_vertex_channel(fobj->VertexCache, timeAtFrame, scene, fobj, i);
+ set_vertex_channel(&eval_ctx, fobj->VertexCache, timeAtFrame, scene, fobj, i);
}
}
}
}
-static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
+static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length)
{
FluidObject *fobj;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
@@ -492,7 +500,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
fsmesh.type = fluidmd->fss->type;
fsmesh.name = ob->id.name;
- initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(&eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
fsmesh.numVertices = numVerts;
fsmesh.numTriangles = numTris;
@@ -1036,7 +1044,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemAddDomain(fsset);
/* ******** export all fluid objects to elbeem ******** */
- export_fluid_objects(fobjects, scene, channels->length);
+ export_fluid_objects(C, fobjects, scene, channels->length);
/* custom data for fluid bake job */
fb->settings = fsset;