Fix missing initialization of depsgraph for snapping context

Was causing crashes once attempting to use snapping.

Reported by mano-wii in IRC, thanks!
This commit is contained in:
Sergey Sharybin
2018-04-18 15:40:51 +02:00
parent 2108142934
commit 3b209a45de
10 changed files with 17 additions and 14 deletions

View File

@@ -998,7 +998,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
* the ideal would be to call this function only at the beginning of the snap operation,
* or at the beginning of the operator itself */
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), CTX_data_scene(C), 0,
CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
CTX_wm_region(C), CTX_wm_view3d(C));
float mvalf[2] = {UNPACK2(dd->mval)};

View File

@@ -5013,7 +5013,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float mval[2] = {UNPACK2(event->mval)};
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), vc.scene, 0, vc.ar, vc.v3d);
CTX_data_main(C), vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
ED_transform_snap_object_project_view3d_mixed(
snap_context,

View File

@@ -29,6 +29,7 @@ struct BMVert;
struct BMEdge;
struct BMFace;
struct Depsgraph;
struct ListBase;
struct Scene;
struct ViewLayer;
@@ -75,9 +76,9 @@ struct SnapObjectParams {
typedef struct SnapObjectContext SnapObjectContext;
SnapObjectContext *ED_transform_snap_object_context_create(
struct Main *bmain, struct Scene *scene, int flag);
struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag);
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
struct Main *bmain, struct Scene *scene, int flag,
struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const struct ARegion *ar, const struct View3D *v3d);
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);

View File

@@ -336,7 +336,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), CTX_data_scene(C), 0,
CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ar, CTX_wm_view3d(C));
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {

View File

@@ -277,7 +277,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), CTX_data_scene(C), 0,
CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {

View File

@@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), CTX_data_scene(C), 0,
CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {

View File

@@ -602,7 +602,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d->rflag |= RV3D_NAVIGATING;
walk->snap_context = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), walk->scene, 0,
CTX_data_main(C), walk->scene, CTX_data_depsgraph(C), 0,
walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(

View File

@@ -593,7 +593,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
G.main, t->scene, 0, t->ar, t->view);
G.main, t->scene, t->depsgraph, 0, t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
t->tsnap.object_context,

View File

@@ -2083,7 +2083,7 @@ static bool snapObjectsRay(
* \{ */
SnapObjectContext *ED_transform_snap_object_context_create(
Main *bmain, Scene *scene, int flag)
Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag)
{
SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__);
@@ -2091,6 +2091,7 @@ SnapObjectContext *ED_transform_snap_object_context_create(
sctx->bmain = bmain;
sctx->scene = scene;
sctx->depsgraph = depsgraph;
sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -2099,11 +2100,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
}
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
Main *bmain, Scene *scene, int flag,
Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const ARegion *ar, const View3D *v3d)
{
SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, flag);
SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, flag);
sctx->use_v3d = true;
sctx->v3d_data.ar = ar;

View File

@@ -163,15 +163,16 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe
}
static void rna_Scene_ray_cast(
Scene *scene, ViewLayer *UNUSED(view_layer),
Scene *scene, ViewLayer *view_layer,
float origin[3], float direction[3], float ray_dist,
int *r_success, float r_location[3], float r_normal[3], int *r_index,
Object **r_ob, float r_obmat[16])
{
normalize_v3(direction);
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
SnapObjectContext *sctx = ED_transform_snap_object_context_create(
G.main, scene, 0);
G.main, scene, depsgraph, 0);
bool ret = ED_transform_snap_object_project_ray_ex(
sctx,