diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-04-11 16:14:49 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-04-11 16:46:01 +0300 |
commit | 9a303d5db789198f8ba3e46d1e482a6b22a67ffe (patch) | |
tree | 0c1085cd5a4ab60a8aa7d5655fc4edaaf2ef5cc8 /source | |
parent | 513aacbdb6e425005eee6d83fdca0f06f6e6e374 (diff) |
Bring snapping back (Base / BaseLegacy)
Diffstat (limited to 'source')
10 files changed, 28 insertions, 21 deletions
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index b53bba8db32..63acb557c52 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -996,7 +996,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_scene_layer(C), 0, CTX_wm_region(C), CTX_wm_view3d(C)); float mvalf[2] = {UNPACK2(dd->mval)}; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f6528658490..09dcdfc35bd 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5015,7 +5015,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, + CTX_data_main(C), vc.scene, vc.sl, 0, vc.ar, vc.v3d); ED_transform_snap_object_project_view3d_mixed( diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h index 6eaae49912c..010f7929e90 100644 --- a/source/blender/editors/include/ED_transform_snap_object_context.h +++ b/source/blender/editors/include/ED_transform_snap_object_context.h @@ -31,6 +31,7 @@ struct BMFace; struct ListBase; struct Scene; +struct SceneLayer; struct Main; struct Object; struct ARegion; @@ -67,9 +68,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 SceneLayer *sl, 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 SceneLayer *sl, int flag, /* extra args for view3d */ const struct ARegion *ar, const struct View3D *v3d); void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index d76dba4088a..576d82ccfac 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -307,7 +307,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_scene_layer(C), 0, ar, CTX_wm_view3d(C)); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 6e9a2c642b6..b3ecc2419a6 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -283,7 +283,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_scene_layer(C), 0, ruler_info->ar, CTX_wm_view3d(C)); } else { diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 5126f305e08..e0c8ad2ed6b 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -249,6 +249,7 @@ typedef struct WalkInfo { View3D *v3d; ARegion *ar; Scene *scene; + SceneLayer *scene_layer; wmTimer *timer; /* needed for redraws */ @@ -511,6 +512,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->v3d = CTX_wm_view3d(C); walk->ar = CTX_wm_region(C); walk->scene = CTX_data_scene(C); + walk->scene_layer = CTX_data_scene_layer(C); #ifdef NDOF_WALK_DEBUG puts("\n-- walk begin --"); @@ -599,7 +601,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, walk->scene_layer, 0, walk->ar, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 02975f73816..a37ca83dcf1 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -78,7 +78,7 @@ #include "transform.h" /* this should be passed as an arg for use in snap functions */ -#undef BASACT +#undef BASACT_NEW /* use half of flt-max so we can scale up without an exception */ @@ -503,8 +503,8 @@ static void initSnappingMode(TransInfo *t) { ToolSettings *ts = t->settings; Object *obedit = t->obedit; - Scene *scene = t->scene; - BaseLegacy *base_act = scene->basact; + SceneLayer *sl = t->sl; + Base *base_act = sl->basact; if (t->spacetype == SPACE_NODE) { /* force project off when not supported */ @@ -585,7 +585,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, + G.main, t->scene, t->sl, 0, t->ar, t->view); ED_transform_snap_object_context_set_editmesh_callbacks( diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 587a62d017d..58474bedb52 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -101,6 +101,7 @@ typedef struct SnapObjectData_EditMesh { struct SnapObjectContext { Main *bmain; Scene *scene; + SceneLayer *scene_layer; int flag; /* Optional: when performing screen-space projection. @@ -1770,7 +1771,7 @@ static bool snapObjectsRay( * * To solve that problem, we do it first as an exception. * */ - BaseLegacy *base_act = sctx->scene->basact; + Base *base_act = sctx->scene_layer->basact; if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) { Object *ob = base_act->object; @@ -1791,11 +1792,11 @@ static bool snapObjectsRay( ignore_object_active = true; break; } - for (BaseLegacy *base = sctx->scene->base.first; base != NULL; base = base->next) { - if ((BASE_VISIBLE_BGMODE(sctx->v3d_data.v3d, sctx->scene, base)) && + for (Base *base = sctx->scene_layer->object_bases.first; base != NULL; base = base->next) { + if ((BASE_VISIBLE_NEW(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 && - !((ignore_object_selected && (base->flag_legacy & (SELECT | BA_WAS_SEL))) || + !((ignore_object_selected && (((base->flag & BASE_SELECTED) != 0) || ((base->flag_legacy & BA_WAS_SEL)))) || (ignore_object_active && base == base_act))) { Object *ob = base->object; @@ -1840,7 +1841,7 @@ static bool snapObjectsRay( * \{ */ SnapObjectContext *ED_transform_snap_object_context_create( - Main *bmain, Scene *scene, int flag) + Main *bmain, Scene *scene, SceneLayer *sl, int flag) { SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__); @@ -1848,6 +1849,7 @@ SnapObjectContext *ED_transform_snap_object_context_create( sctx->bmain = bmain; sctx->scene = scene; + sctx->scene_layer = sl; sctx->cache.object_map = BLI_ghash_ptr_new(__func__); sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); @@ -1856,11 +1858,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, SceneLayer *sl, 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, sl, flag); sctx->use_v3d = true; sctx->v3d_data.ar = ar; diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 2112f51debb..7fc0612bb6e 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -152,14 +152,14 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe } static void rna_Scene_ray_cast( - Scene *scene, float origin[3], float direction[3], float ray_dist, + Scene *scene, SceneLayer *sl, 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); SnapObjectContext *sctx = ED_transform_snap_object_context_create( - G.main, scene, 0); + G.main, scene, sl, 0); bool ret = ED_transform_snap_object_project_ray_ex( sctx, @@ -347,6 +347,8 @@ void RNA_api_scene(StructRNA *srna) /* Ray Cast */ func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast"); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); + parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene Layer"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); /* ray start and end */ parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index aa3b89c6fdf..032c9174217 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -549,7 +549,7 @@ bool ED_text_region_location_from_cursor(SpaceText *st, ARegion *ar, const int c SnapObjectContext *ED_transform_snap_object_context_create( struct Main *bmain, struct Scene *scene, int flag) RET_NULL SnapObjectContext *ED_transform_snap_object_context_create_view3d( - struct Main *bmain, struct Scene *scene, int flag, + struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, int flag, const struct ARegion *ar, const struct View3D *v3d) RET_NULL void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) RET_NONE bool ED_transform_snap_object_project_ray_ex( |