Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_snap_object.c
| Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| static void iter_snap_objects( | static void iter_snap_objects( | ||||
| SnapObjectContext *sctx, | SnapObjectContext *sctx, | ||||
| const eSnapSelect snap_select, | const eSnapSelect snap_select, | ||||
| Object *obedit, | Object *obedit, | ||||
| IterSnapObjsCallback sob_callback, | IterSnapObjsCallback sob_callback, | ||||
| void *data) | void *data) | ||||
| { | { | ||||
| Base *base_act = sctx->eval_ctx.scene_layer->basact; | Base *base_act = sctx->eval_ctx.view_layer->basact; | ||||
| /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA | /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA | ||||
| * which makes the loop skip it, even the derived mesh will never change | * which makes the loop skip it, even the derived mesh will never change | ||||
| * | * | ||||
| * To solve that problem, we do it first as an exception. | * To solve that problem, we do it first as an exception. | ||||
| * */ | * */ | ||||
| if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) { | if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) { | ||||
| sob_callback(sctx, false, base_act->object, base_act->object->obmat, data); | sob_callback(sctx, false, base_act->object, base_act->object->obmat, data); | ||||
| } | } | ||||
| for (Base *base = sctx->eval_ctx.scene_layer->object_bases.first; base != NULL; base = base->next) { | for (Base *base = sctx->eval_ctx.view_layer->object_bases.first; base != NULL; base = base->next) { | ||||
| if ((BASE_VISIBLE(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 && | if ((BASE_VISIBLE(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 && | ||||
| !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) || | !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) || | ||||
| (snap_select == SNAP_NOT_ACTIVE && base == base_act))) | (snap_select == SNAP_NOT_ACTIVE && base == base_act))) | ||||
| { | { | ||||
| bool use_obedit; | bool use_obedit; | ||||
| Object *obj = base->object; | Object *obj = base->object; | ||||
| if (obj->transflag & OB_DUPLI) { | if (obj->transflag & OB_DUPLI) { | ||||
| DupliObject *dupli_ob; | DupliObject *dupli_ob; | ||||
| ▲ Show 20 Lines • Show All 1,909 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Public Object Snapping API | /** \name Public Object Snapping API | ||||
| * \{ */ | * \{ */ | ||||
| SnapObjectContext *ED_transform_snap_object_context_create( | SnapObjectContext *ED_transform_snap_object_context_create( | ||||
| Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag) | Main *bmain, Scene *scene, ViewLayer *sl, RenderEngineType *engine, int flag) | ||||
| { | { | ||||
| SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__); | SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__); | ||||
| sctx->flag = flag; | sctx->flag = flag; | ||||
| sctx->bmain = bmain; | sctx->bmain = bmain; | ||||
| sctx->scene = scene; | sctx->scene = scene; | ||||
| DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, engine, DAG_EVAL_VIEWPORT); | DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, engine, DAG_EVAL_VIEWPORT); | ||||
| sctx->cache.object_map = BLI_ghash_ptr_new(__func__); | sctx->cache.object_map = BLI_ghash_ptr_new(__func__); | ||||
| sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); | sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); | ||||
| return sctx; | return sctx; | ||||
| } | } | ||||
| SnapObjectContext *ED_transform_snap_object_context_create_view3d( | SnapObjectContext *ED_transform_snap_object_context_create_view3d( | ||||
| Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag, | Main *bmain, Scene *scene, ViewLayer *sl, RenderEngineType *engine, int flag, | ||||
| /* extra args for view3d */ | /* extra args for view3d */ | ||||
| const ARegion *ar, const View3D *v3d) | const ARegion *ar, const View3D *v3d) | ||||
| { | { | ||||
| SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, engine, flag); | SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, engine, flag); | ||||
| sctx->use_v3d = true; | sctx->use_v3d = true; | ||||
| sctx->v3d_data.ar = ar; | sctx->v3d_data.ar = ar; | ||||
| sctx->v3d_data.v3d = v3d; | sctx->v3d_data.v3d = v3d; | ||||
| ▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines | |||||