[Bf-blender-cvs] [254bb922e86] blender2.8: Cleanup: avoid passing bContext to particle API
Campbell Barton
noreply at git.blender.org
Mon Mar 19 19:05:13 CET 2018
Commit: 254bb922e8654a85b3c3e2c715cb4a078f832bcb
Author: Campbell Barton
Date: Mon Mar 19 19:03:18 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB254bb922e8654a85b3c3e2c715cb4a078f832bcb
Cleanup: avoid passing bContext to particle API
Also add EvaluationContext to PEData
===================================================================
M source/blender/editors/include/ED_particle.h
M source/blender/editors/physics/particle_edit.c
M source/blender/editors/physics/particle_object.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/transform/transform_conversions.c
===================================================================
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index ffa6db18caa..ee60d1c8eef 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -55,7 +55,7 @@ struct ParticleEditSettings *PE_settings(struct Scene *scene);
void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra);
void PE_update_object(
const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct Object *ob, int useflag);
+ 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/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index e1dcec1d9ab..224790269e2 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -351,6 +351,7 @@ typedef struct PEData {
DerivedMesh *dm;
PTCacheEdit *edit;
BVHTreeFromMesh shape_bvh;
+ EvaluationContext eval_ctx;
const int *mval;
rcti *rect;
@@ -383,6 +384,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->edit = PE_get_current(data->scene, data->view_layer, data->ob);
}
@@ -394,13 +396,10 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
if (V3D_IS_ZBUF(data->vc.v3d)) {
if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_backbuf_validate(&eval_ctx, &data->vc);
+ ED_view3d_backbuf_validate(&data->eval_ctx, &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; */
@@ -1145,15 +1144,12 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys)
BLI_kdtree_balance(edit->emitter_field);
}
-static void PE_update_selection(const bContext *C, Scene *scene, ViewLayer *view_layer, Object *ob, int useflag)
+static void PE_update_selection(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int useflag)
{
- PTCacheEdit *edit = PE_get_current(scene, view_layer, ob);
+ PTCacheEdit *edit = PE_get_current(scene, eval_ctx->view_layer, 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
@@ -1169,7 +1165,7 @@ static void PE_update_selection(const bContext *C, Scene *scene, ViewLayer *view
}
}
- psys_cache_edit_paths(&eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
@@ -1255,12 +1251,12 @@ static void update_velocities(PTCacheEdit *edit)
}
}
-void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, Object *ob, int useflag)
+void PE_update_object(const EvaluationContext *eval_ctx, 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, view_layer, ob);
+ PTCacheEdit *edit = PE_get_current(scene, eval_ctx->view_layer, ob);
POINT_P;
if (!edit)
@@ -1397,9 +1393,10 @@ 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);
- ViewLayer *view_layer = CTX_data_view_layer(C);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob= CTX_data_active_object(C);
- PTCacheEdit *edit= PE_get_current(scene, view_layer, ob);
+ PTCacheEdit *edit= PE_get_current(scene, eval_ctx.view_layer, ob);
POINT_P; KEY_K;
int action = RNA_enum_get(op->ptr, "action");
@@ -1422,7 +1419,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(C, scene, view_layer, ob, 1);
+ PE_update_selection(&eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1480,7 +1477,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(C, scene, view_layer, ob, 1);
+ PE_update_selection(&data.eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1521,7 +1518,7 @@ static int select_roots_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_root);
- PE_update_selection(C, data.scene, data.view_layer, data.ob, 1);
+ PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1586,7 +1583,7 @@ static int select_tips_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_tip);
- PE_update_selection(C, data.scene, data.view_layer, data.ob, 1);
+ PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1625,7 +1622,6 @@ static int select_random_exec(bContext *C, wmOperator *op)
PEData data;
int type;
Scene *scene;
- ViewLayer *view_layer;
Object *ob;
/* used by LOOP_VISIBLE_POINTS, LOOP_VISIBLE_KEYS and LOOP_KEYS */
@@ -1645,9 +1641,8 @@ static int select_random_exec(bContext *C, wmOperator *op)
PE_set_data(C, &data);
data.select_action = SEL_SELECT;
scene = CTX_data_scene(C);
- view_layer = CTX_data_view_layer(C);
ob = CTX_data_active_object(C);
- edit = PE_get_current(scene, view_layer, ob);
+ edit = PE_get_current(scene, data.eval_ctx.view_layer, ob);
rng = BLI_rng_new_srandom(seed);
@@ -1672,7 +1667,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- PE_update_selection(C, data.scene, data.view_layer, data.ob, 1);
+ PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1716,7 +1711,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(C, data.scene, data.view_layer, data.ob, 1);
+ PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1781,7 +1776,7 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend)
for_mouse_hit_keys(&data, select_key, 0);
- PE_update_selection(C, scene, view_layer, ob, 1);
+ PE_update_selection(&data.eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1807,7 +1802,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(C, scene, view_layer, ob, 1);
+ PE_update_selection(&data.eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1896,7 +1891,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
}
}
- PE_update_selection(C, scene, view_layer, ob, 1);
+ PE_update_selection(&data.eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1908,10 +1903,13 @@ static int hide_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- PTCacheEdit *edit= PE_get_current(scene, view_layer, ob);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ PTCacheEdit *edit= PE_get_current(scene, eval_ctx.view_layer, ob);
POINT_P; KEY_K;
-
+
+
if (RNA_enum_get(op->ptr, "unselected")) {
LOOP_UNSELECTED_POINTS {
point->flag |= PEP_HIDE;
@@ -1931,7 +1929,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(C, scene, view_layer, ob, 1);
+ PE_update_selection(&eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1961,8 +1959,9 @@ static int reveal_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- PTCacheEdit *edit= PE_get_current(scene, view_layer, ob);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ PTCacheEdit *edit= PE_get_current(scene, eval_ctx.view_layer, ob);
const bool select = RNA_boolean_get(op->ptr, "select");
POINT_P; KEY_K;
@@ -1977,7 +1976,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(C, scene, view_layer, ob, 1);
+ PE_update_selection(&eval_ctx, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -2039,7 +2038,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(C, data.scene, data.view_layer, data.ob, 1);
+ PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2101,7 +2100,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(C
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list