diff options
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 10 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 199 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 69 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 26 | ||||
-rw-r--r-- | source/blender/editors/physics/rigidbody_constraint.c | 4 |
5 files changed, 197 insertions, 111 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..6a5a3c73f81 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -86,7 +86,9 @@ #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 EvaluationContext *eval_ctx, 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 +218,8 @@ 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 EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, int create) { ParticleEditSettings *pset= PE_settings(scene); PTCacheEdit *edit = NULL; @@ -256,18 +259,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(eval_ctx, 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(eval_ctx, 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(eval_ctx, scene, sl, ob, pid->cache, psys); edit = pid->cache->edit; } @@ -278,7 +281,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(eval_ctx, scene, sl, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -287,7 +290,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(eval_ctx, scene, sl, ob, pid->cache, NULL); } edit = pid->cache->edit; break; @@ -304,18 +307,19 @@ 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 EvaluationContext *eval_ctx, Scene *scene, Object *ob) { - return pe_get_current(scene, NULL, ob, 1); + return pe_get_current(eval_ctx, scene, NULL, ob, 1); } -void PE_current_changed(Scene *scene, Object *ob) +void PE_current_changed(const EvaluationContext *eval_ctx, Scene *scene, Object *ob) { - if (ob->mode == OB_MODE_PARTICLE_EDIT) - PE_create_current(scene, ob); + if (ob->mode == OB_MODE_PARTICLE_EDIT) { + PE_create_current(eval_ctx, scene, ob); + } } void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) @@ -358,6 +362,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 +398,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) @@ -407,10 +412,13 @@ 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(&data->vc); + ED_view3d_backbuf_validate(&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; */ @@ -429,7 +437,6 @@ static bool PE_create_shape_tree(PEData *data, Object *shapeob) return false; } - DM_ensure_looptri(dm); return (bvhtree_from_mesh_looptri(&data->shape_bvh, dm, 0.0f, 4, 8) != NULL); } @@ -1156,12 +1163,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 +1187,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,7 +1273,7 @@ static void update_velocities(PTCacheEdit *edit) } } -void PE_update_object(Scene *scene, SceneLayer *sl, Object *ob, int useflag) +void PE_update_object(const EvaluationContext *eval_ctx, 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 */ @@ -1293,7 +1303,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 +1438,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 +1471,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 +1496,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 +1537,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 +1602,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 +1688,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 +1732,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 +1797,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 +1823,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 +1912,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 +1947,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 +1991,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 +2050,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 +2112,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 +2145,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; @@ -2191,6 +2204,9 @@ 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); @@ -2199,7 +2215,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(&eval_ctx, 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 +2240,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 +2471,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) @@ -2526,11 +2549,14 @@ 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(data.scene, data.scene_layer, data.ob, 1); + PE_update_object(&eval_ctx, data.scene, data.scene_layer, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); return OPERATOR_FINISHED; @@ -2720,7 +2746,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - imm_draw_circle_wire(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40); + imm_draw_circle_wire_2d(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); @@ -2813,7 +2839,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 +3127,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 +3375,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 +3509,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 +3539,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 +3582,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; @@ -3798,6 +3831,9 @@ 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); + RNA_float_get_array(itemptr, "mouse", mousef); mouse[0] = mousef[0]; mouse[1] = mousef[1]; @@ -3923,7 +3959,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); @@ -3979,8 +4015,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } - else - PE_update_object(scene, sl, ob, 1); + else { + PE_update_object(&eval_ctx, scene, sl, ob, 1); + } } if (edit->psys) { @@ -4193,7 +4230,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; } } @@ -4213,6 +4250,9 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + /* disable locking temporatily for disconnected hair */ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) pset->flag &= ~PE_LOCK_FIRST; @@ -4240,8 +4280,9 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } - else - PE_update_object(scene, sl, ob, 1); + else { + PE_update_object(&eval_ctx, scene, sl, ob, 1); + } if (edit->psys) { WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); @@ -4415,7 +4456,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) void PE_undo_push(Scene *scene, SceneLayer *sl, const char *str) { - PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW); + PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl)); PTCacheUndo *undo; int nr; @@ -4457,7 +4498,7 @@ void PE_undo_push(Scene *scene, SceneLayer *sl, const char *str) void PE_undo_step(Scene *scene, SceneLayer *sl, int step) { - PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW); + PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl)); if (!edit) return; @@ -4488,12 +4529,12 @@ void PE_undo_step(Scene *scene, SceneLayer *sl, int step) } } - DEG_id_tag_update(&OBACT_NEW->id, OB_RECALC_DATA); + DEG_id_tag_update(&OBACT_NEW(sl)->id, OB_RECALC_DATA); } bool PE_undo_is_valid(Scene *scene, SceneLayer *sl) { - PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW); + PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl)); if (edit) { return (edit->undo.last != edit->undo.first); @@ -4528,7 +4569,7 @@ void PE_redo(Scene *scene, SceneLayer *sl) void PE_undo_number(Scene *scene, SceneLayer *sl, int nr) { - PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW); + PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl)); PTCacheUndo *undo; int a=0; @@ -4544,7 +4585,7 @@ void PE_undo_number(Scene *scene, SceneLayer *sl, int nr) /* if active pointer, set it to 1 if true */ const char *PE_undo_get_name(Scene *scene, SceneLayer *sl, int nr, bool *r_active) { - PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW); + PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl)); PTCacheUndo *undo; if (r_active) *r_active = false; @@ -4565,7 +4606,7 @@ const char *PE_undo_get_name(Scene *scene, SceneLayer *sl, int nr, bool *r_activ int PE_minmax(Scene *scene, SceneLayer *sl, float min[3], float max[3]) { - Object *ob= OBACT_NEW; + Object *ob= OBACT_NEW(sl); PTCacheEdit *edit= PE_get_current(scene, sl, ob); ParticleSystem *psys; ParticleSystemModifierData *psmd = NULL; @@ -4603,7 +4644,8 @@ 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 EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys) { PTCacheEdit *edit; ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL; @@ -4704,7 +4746,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(eval_ctx, scene, sl, ob, 1); PTCacheUndo_clear(edit); PE_undo_push(scene, sl, "Original"); @@ -4745,8 +4787,11 @@ 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(scene, ob); + edit= PE_create_current(&eval_ctx, 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 */ @@ -4917,12 +4962,16 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) SceneLayer *sl = CTX_data_scene_layer(C); PTCacheEdit *edit = PE_get_current(scene, sl, 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, sl, ob, 1); + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + + PE_update_object(&eval_ctx, 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..571a8ab18f0 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,9 @@ 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 EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, + Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); ParticleEditSettings *pset= PE_settings(scene); @@ -614,7 +616,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(eval_ctx, scene, sl, ob, 0); } static int disconnect_hair_exec(bContext *C, wmOperator *op) @@ -625,17 +627,20 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op) ParticleSystem *psys= NULL; const bool all = RNA_boolean_get(op->ptr, "all"); + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + if (!ob) return OPERATOR_CANCELLED; if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - disconnect_hair(scene, sl, ob, psys); + disconnect_hair(&eval_ctx, scene, sl, ob, psys); } } else { psys = psys_get_current(ob); - disconnect_hair(scene, sl, ob, psys); + disconnect_hair(&eval_ctx, scene, sl, ob, psys); } DEG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -661,9 +666,10 @@ 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, - 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) +static bool remap_hair_emitter( + const EvaluationContext *eval_ctx, 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) { ParticleSystemModifierData *target_psmd = psys_get_modifier(target_ob, target_psys); ParticleData *pa, *tpa; @@ -847,19 +853,23 @@ 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(eval_ctx, scene, sl, target_ob, 0); return true; } -static bool connect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys) +static bool connect_hair( + const EvaluationContext *eval_ctx, 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( + eval_ctx, 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; @@ -867,6 +877,7 @@ static bool connect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSyste static int connect_hair_exec(bContext *C, wmOperator *op) { + EvaluationContext eval_ctx; Scene *scene= CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); Object *ob= ED_object_context(C); @@ -877,14 +888,16 @@ static int connect_hair_exec(bContext *C, wmOperator *op) if (!ob) return OPERATOR_CANCELLED; + CTX_data_eval_ctx(C, &eval_ctx); + if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - any_connected |= connect_hair(scene, sl, ob, psys); + any_connected |= connect_hair(&eval_ctx, scene, sl, ob, psys); } } else { psys = psys_get_current(ob); - any_connected |= connect_hair(scene, sl, ob, psys); + any_connected |= connect_hair(&eval_ctx, scene, sl, ob, psys); } if (!any_connected) { @@ -920,7 +933,9 @@ 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 EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, + Object *ob, ParticleSystem *psys, ParticleSystem *psys_from) { PTCacheEdit *edit_from = psys_from->edit, *edit; ParticleData *pa; @@ -970,7 +985,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(eval_ctx, scene, sl, ob, true); PTCacheUndo_clear(edit); PE_undo_push(scene, sl, "Original"); @@ -1001,7 +1016,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 +1025,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 +1034,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)) @@ -1041,7 +1060,7 @@ static bool copy_particle_systems_to_object(Main *bmain, psys_from; psys_from = PSYS_FROM_NEXT(psys_from), ++i) { - psys = BKE_object_copy_particlesystem(psys_from); + psys = BKE_object_copy_particlesystem(psys_from, 0); tmp_psys[i] = psys; if (psys_start == NULL) @@ -1055,7 +1074,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; @@ -1083,8 +1102,9 @@ static bool copy_particle_systems_to_object(Main *bmain, CDDM_calc_normals(psmd->dm_final); DM_ensure_tessface(psmd->dm_final); - if (psys_from->edit) - copy_particle_edit(scene, sl, ob_to, psys, psys_from); + if (psys_from->edit) { + copy_particle_edit(&eval_ctx, scene, sl, ob_to, psys, psys_from); + } if (duplicate_settings) { id_us_min(&psys->part->id); @@ -1118,7 +1138,9 @@ 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( + &eval_ctx, 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 +1173,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 +1189,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 +1250,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..b38b8640c8d 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); @@ -344,7 +349,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); /* allocate fluid objects */ - for (base = FIRSTBASE_NEW; base; base = base->next) { + for (base = FIRSTBASE_NEW(sl); base; base = base->next) { Object *ob = base->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -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; @@ -578,7 +586,7 @@ static int fluid_validate_scene(ReportList *reports, SceneLayer *sl, Object *fsD int channelObjCount = 0; int fluidInputCount = 0; - for (base = FIRSTBASE_NEW; base; base = base->next) { + for (base = FIRSTBASE_NEW(sl); base; base = base->next) { Object *ob = base->object; FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -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; diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index d93eb95243e..1c9b59268e4 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -121,7 +121,7 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); - Object *ob = OBACT_NEW; + Object *ob = OBACT_NEW(sl); int type = RNA_enum_get(op->ptr, "type"); bool changed; @@ -170,7 +170,7 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); - Object *ob = OBACT_NEW; + Object *ob = OBACT_NEW(sl); /* apply to active object */ if (ELEM(NULL, ob, ob->rigidbody_constraint)) { |