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:
Diffstat (limited to 'source/blender/editors/physics/particle_edit.c')
-rw-r--r--source/blender/editors/physics/particle_edit.c128
1 files changed, 52 insertions, 76 deletions
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);
}