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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-07-25 17:36:22 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-07-31 17:55:15 +0300
commit3566b81c8bfa8c69d542a5de29ecb8d5af3ccb3d (patch)
tree8c549ae6f2b1064399a7c0b99ab6ce9b287bdd28 /source/blender/editors/physics
parentf5f3003874f26681000618032d88482367348064 (diff)
Refactor access to dependency graph
This change ensures that operators which needs access to evaluated data first makes sure there is a dependency graph. Other accesses to the dependency graph made it more explicit about whether they just need a valid dependency graph pointer or whether they expect the graph to be already evaluated. This replaces OPTYPE_USE_EVAL_DATA which is now removed. Some general rules about usage of accessors: - Drawing is expected to happen from a fully evaluated dependency graph. There is now a function to access it, which will in the future control that dependency graph is actually evaluated. This check is not yet done because there are some things to be taken care about first: for example, post-update hooks might leave scene in a state where something is still tagged for update. - All operators which needs to access evaluated state must use CTX_data_ensure_evaluated_depsgraph(). This function replaces OPTYPE_USE_EVAL_DATA. The call is generally to be done in the very beginning of the operator, prior other logic (unless this is some comprehensive operator which might or might not need access to an evaluated state). This call is never to be used from a loop. If some utility function requires evaluated state of dependency graph the graph is to be passed as an explicit argument. This way it is clear that no evaluation happens in a loop or something like this. - All cases which needs to know dependency graph pointer, but which doesn't want to actually evaluate it can use old-style function CTX_data_depsgraph_pointer(), assuming that underlying code will ensure dependency graph is evaluated prior to accessing it. - The new functions are replacing OPTYPE_USE_EVAL_DATA, so now it is explicit and local about where dependency graph is being ensured. This commit also contains some fixes of wrong usage of evaluation functions on original objects. Ideally should be split out, but in reality with all the APIs being renamed is quite tricky. Fixes T67454: Blender crash on rapid undo and select Speculation here is that sometimes undo and selection operators are sometimes handled in the same event loop iteration, which leaves non-evaluated dependency graph. Fixes T67973: Crash on Fix Deforms operator Fixes T67902: Crash when undo a loop cut Reviewers: brecht Reviewed By: brecht Subscribers: lichtwerk Maniphest Tasks: T67454 Differential Revision: https://developer.blender.org/D5343
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c4
-rw-r--r--source/blender/editors/physics/particle_edit.c18
-rw-r--r--source/blender/editors/physics/particle_object.c6
-rw-r--r--source/blender/editors/physics/physics_fluid.c16
-rw-r--r--source/blender/editors/physics/physics_pointcache.c3
-rw-r--r--source/blender/editors/physics/rigidbody_object.c4
6 files changed, 27 insertions, 24 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 40b7a245f69..c06c21b9057 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -473,7 +473,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update
*/
static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob_ = ED_object_context(C);
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
@@ -505,7 +505,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
job->bmain = CTX_data_main(C);
job->scene = scene_eval;
- job->depsgraph = CTX_data_depsgraph(C);
+ job->depsgraph = depsgraph;
job->ob = object_eval;
job->canvas = canvas;
job->surface = surface;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index ebf62f282c2..e6870cda19d 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -465,7 +465,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);
- data->depsgraph = CTX_data_depsgraph(C);
+ data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
data->edit = PE_get_current(data->scene, data->ob);
}
@@ -1778,7 +1778,7 @@ static bool select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in
static int pe_select_all_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
@@ -2348,7 +2348,7 @@ static int hide_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
@@ -2409,7 +2409,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
const bool select = RNA_boolean_get(op->ptr, "select");
POINT_P;
@@ -2709,7 +2709,7 @@ static void rekey_particle_to_time(
psys = edit->psys;
- sim.depsgraph = CTX_data_depsgraph(C);
+ sim.depsgraph = CTX_data_depsgraph_pointer(C);
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -4211,7 +4211,7 @@ static void brush_add_count_iter_finalize(void *__restrict userdata_v,
static int brush_add(const bContext *C, PEData *data, short number)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = data->scene;
Object *ob = data->ob;
Mesh *mesh;
@@ -4542,7 +4542,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
{
BrushEdit *bedit = op->customdata;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = bedit->scene;
Object *ob = bedit->ob;
PTCacheEdit *edit = bedit->edit;
@@ -5294,7 +5294,7 @@ static void free_all_psys_edit(Object *object)
static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_PARTICLE_EDIT;
@@ -5495,7 +5495,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
float average_length = calculate_average_length(edit);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 71877fc6b39..0999d1f3588 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -652,7 +652,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
static int disconnect_hair_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
ParticleSystem *psys = NULL;
@@ -934,7 +934,7 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl
static int connect_hair_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
ParticleSystem *psys = NULL;
@@ -1086,7 +1086,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
bool duplicate_settings)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index dc3673c972f..da0fb873075 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -334,6 +334,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
}
static void fluid_init_all_channels(bContext *C,
+ Depsgraph *depsgraph,
Object *UNUSED(fsDomain),
FluidsimSettings *domainSettings,
FluidAnimChannels *channels,
@@ -341,7 +342,6 @@ static void fluid_init_all_channels(bContext *C,
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Base *base;
int i;
int length = channels->length;
@@ -514,9 +514,11 @@ static void fluid_init_all_channels(bContext *C,
}
}
-static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length)
+static void export_fluid_objects(Depsgraph *depsgraph,
+ ListBase *fobjects,
+ Scene *scene,
+ int length)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
FluidObject *fobj;
for (fobj = fobjects->first; fobj; fobj = fobj->next) {
@@ -922,7 +924,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
int i;
FluidsimSettings *domainSettings;
@@ -1051,11 +1053,11 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
(double)noFrames;
/* ******** initialize and allocate animation channels ******** */
- fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);
+ fluid_init_all_channels(C, depsgraph, fsDomain, domainSettings, channels, fobjects);
/* reset to original current frame */
scene->r.cfra = origFrame;
- ED_update_for_newframe(CTX_data_main(C), depsgraph);
+ ED_update_for_newframe(CTX_data_main(C), CTX_data_depsgraph_pointer(C));
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);
@@ -1153,7 +1155,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemAddDomain(fsset);
/* ******** export all fluid objects to elbeem ******** */
- export_fluid_objects(C, fobjects, scene, channels->length);
+ export_fluid_objects(depsgraph, fobjects, scene, channels->length);
/* custom data for fluid bake job */
fb->settings = fsset;
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index e9e89a31f94..bc2f1d6cef6 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -156,7 +156,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
baker->bmain = CTX_data_main(C);
baker->scene = CTX_data_scene(C);
baker->view_layer = CTX_data_view_layer(C);
- baker->depsgraph = CTX_data_depsgraph(C);
+ /* Depsgraph is used to sweep the frame range and evaluate scene at different times. */
+ baker->depsgraph = CTX_data_depsgraph_pointer(C);
baker->bake = RNA_boolean_get(op->ptr, "bake");
baker->render = 0;
baker->anim_init = 0;
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index aa323dc53eb..70142b790c0 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -464,7 +464,7 @@ static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C),
static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
int material = RNA_enum_get(op->ptr, "material");
float density;
bool changed = false;
@@ -537,7 +537,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = prop = RNA_def_enum(