diff options
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 266 |
1 files changed, 115 insertions, 151 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 20820e9d766..57a8f2e46d7 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -36,6 +36,7 @@ #include "DNA_curve_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "MEM_guardedalloc.h" @@ -46,14 +47,18 @@ #include "BKE_camera.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ #include "BKE_main.h" #include "BKE_object.h" #include "BKE_screen.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_matrix.h" + #include "WM_api.h" #include "WM_types.h" @@ -61,6 +66,8 @@ #include "ED_screen.h" #include "ED_view3d.h" +#include "UI_resources.h" + #include "view3d_intern.h" /* own include */ /* -------------------------------------------------------------------- */ @@ -68,10 +75,33 @@ * * \{ */ -float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d) +void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float r_color[3]) { - if (v3d && v3d->localvd) return v3d->cursor; - else return scene->cursor; + if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD) { + if (scene->world) { + copy_v3_v3(r_color, &scene->world->horr); + return; + } + } + else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_VIEWPORT) { + copy_v3_v3(r_color, v3d->shading.background_color); + return; + } + + UI_GetThemeColor3fv(TH_BACK, r_color); +} + +void ED_view3d_cursor3d_calc_mat3(const Scene *scene, float mat[3][3]) +{ + const View3DCursor *cursor = &scene->cursor; + quat_to_mat3(mat, cursor->rotation); +} + +void ED_view3d_cursor3d_calc_mat4(const Scene *scene, float mat[4][4]) +{ + const View3DCursor *cursor = &scene->cursor; + quat_to_mat4(mat, cursor->rotation); + copy_v3_v3(mat[3], cursor->location); } Camera *ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d) @@ -98,6 +128,7 @@ void ED_view3d_dist_range_get( * \note copies logic of #ED_view3d_viewplane_get(), keep in sync. */ bool ED_view3d_clip_range_get( + Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, float *r_clipsta, float *r_clipend, const bool use_ortho_factor) @@ -105,7 +136,7 @@ bool ED_view3d_clip_range_get( CameraParams params; BKE_camera_params_init(¶ms); - BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); if (use_ortho_factor && params.is_ortho) { const float fac = 2.0f / (params.clipend - params.clipsta); @@ -120,13 +151,14 @@ bool ED_view3d_clip_range_get( } bool ED_view3d_viewplane_get( + Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, int winx, int winy, rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize) { CameraParams params; BKE_camera_params_init(¶ms); - BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); BKE_camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); if (r_viewplane) *r_viewplane = params.viewplane; @@ -157,7 +189,7 @@ void view3d_operator_needs_opengl(const bContext *C) view3d_region_operator_needs_opengl(win, ar); } -void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) +void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *ar) { /* for debugging purpose, context should always be OK */ if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW)) { @@ -166,11 +198,9 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) else { RegionView3D *rv3d = ar->regiondata; - wmSubWindowSet(win, ar->swinid); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(rv3d->winmat); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(rv3d->viewmat); + wmViewport(&ar->winrct); // TODO: bad + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } } @@ -232,6 +262,7 @@ bool ED_view3d_context_activate(bContext *C) /** \name View Clipping Utilities * * \{ */ + void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], const BoundBox *bb, const bool is_flip) { int val; @@ -246,40 +277,35 @@ void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], const BoundBox *bb, } } -void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect) +void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *ar, const Object *ob, const rcti *rect) { - float modelview[4][4]; - double xs, ys, p[3]; - int val, flip_sign, a; - - /* near zero floating point values can give issues with gluUnProject - * in side view on some implementations */ - if (fabs(mats->modelview[0]) < 1e-6) mats->modelview[0] = 0.0; - if (fabs(mats->modelview[5]) < 1e-6) mats->modelview[5] = 0.0; - - /* Set up viewport so that gluUnProject will give correct values */ - mats->viewport[0] = 0; - mats->viewport[1] = 0; + /* init in case unproject fails */ + memset(bb->vec, 0, sizeof(bb->vec)); /* four clipping planes and bounding volume */ /* first do the bounding volume */ - for (val = 0; val < 4; val++) { - xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax; - ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax; + for (int val = 0; val < 4; val++) { + float xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax; + float ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax; - gluUnProject(xs, ys, 0.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]); - copy_v3fl_v3db(bb->vec[val], p); + ED_view3d_unproject(ar, xs, ys, 0.0, bb->vec[val]); + ED_view3d_unproject(ar, xs, ys, 1.0, bb->vec[4 + val]); + } - gluUnProject(xs, ys, 1.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]); - copy_v3fl_v3db(bb->vec[4 + val], p); + /* optionally transform to object space */ + if (ob) { + float imat[4][4]; + invert_m4_m4(imat, ob->obmat); + + for (int val = 0; val < 8; val++) { + mul_m4_v3(imat, bb->vec[val]); + } } /* verify if we have negative scale. doing the transform before cross * product flips the sign of the vector compared to doing cross product * before transform then, so we correct for that. */ - for (a = 0; a < 16; a++) - ((float *)modelview)[a] = mats->modelview[a]; - flip_sign = is_negative_m4(modelview); + int flip_sign = (ob) ? is_negative_m4(ob->obmat) : false; ED_view3d_clipping_calc_from_boundbox(planes, bb, flip_sign); } @@ -380,14 +406,15 @@ void ED_view3d_lock_clear(View3D *v3d) * sets the ``ofs`` and ``dist`` values of the viewport so it matches the camera, * otherwise switching out of camera view may jump to a different part of the scene. */ -void ED_view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const char persp) +void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d, const char persp) { BLI_assert(rv3d->persp == RV3D_CAMOB); BLI_assert(persp != RV3D_CAMOB); if (v3d->camera) { - rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK); - ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); + rv3d->dist = ED_view3d_offset_distance(ob_camera_eval->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK); + ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } if (!ED_view3d_camera_lock_check(v3d, rv3d)) { @@ -400,7 +427,7 @@ void ED_view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const c * * shared with NDOF. */ -bool ED_view3d_persp_ensure(struct View3D *v3d, ARegion *ar) +bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar) { RegionView3D *rv3d = ar->regiondata; const bool autopersp = (U.uiflag & USER_AUTOPERSP) != 0; @@ -415,7 +442,7 @@ bool ED_view3d_persp_ensure(struct View3D *v3d, ARegion *ar) /* If autopersp and previous view was an axis one, * switch back to PERSP mode, else reuse previous mode. */ char persp = (autopersp && RV3D_VIEW_IS_AXIS(rv3d->lview)) ? RV3D_PERSP : rv3d->lpersp; - ED_view3d_persp_switch_from_camera(v3d, rv3d, persp); + ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, persp); } else if (autopersp && RV3D_VIEW_IS_AXIS(rv3d->view)) { rv3d->persp = RV3D_PERSP; @@ -449,20 +476,21 @@ bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d) * Apply the camera object transformation to the view-port. * (needed so we can use regular view-port manipulation operators, that sync back to the camera). */ -void ED_view3d_camera_lock_init_ex(View3D *v3d, RegionView3D *rv3d, const bool calc_dist) +void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d, const bool calc_dist) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { + Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); if (calc_dist) { /* using a fallback dist is OK here since ED_view3d_from_object() compensates for it */ - rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK); + rv3d->dist = ED_view3d_offset_distance(ob_camera_eval->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK); } - ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } } -void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) +void ED_view3d_camera_lock_init(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d) { - ED_view3d_camera_lock_init_ex(v3d, rv3d, true); + ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, true); } /** @@ -470,7 +498,7 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) * * \return true if the camera is moved. */ -bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) +bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { ObjectTfmProtectedChannels obtfm; @@ -487,15 +515,17 @@ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) while (root_parent->parent) { root_parent = root_parent->parent; } + Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); + Object *root_parent_eval = DEG_get_evaluated_object(depsgraph, root_parent); ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - normalize_m4_m4(tmat, v3d->camera->obmat); + normalize_m4_m4(tmat, ob_camera_eval->obmat); invert_m4_m4(imat, tmat); mul_m4_m4m4(diff_mat, view_mat, imat); - mul_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); + mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->obmat); BKE_object_tfm_protected_backup(root_parent, &obtfm); BKE_object_apply_mat4(root_parent, parent_mat, true, false); @@ -503,7 +533,7 @@ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) ob_update = v3d->camera; while (ob_update) { - DAG_id_tag_update(&ob_update->id, OB_RECALC_OB); + DEG_id_tag_update(&ob_update->id, ID_RECALC_TRANSFORM); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, ob_update); ob_update = ob_update->parent; } @@ -512,10 +542,10 @@ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) /* always maintain the same scale */ const short protect_scale_all = (OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ); BKE_object_tfm_protected_backup(v3d->camera, &obtfm); - ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); + ED_view3d_to_object(depsgraph, v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag | protect_scale_all); - DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); + DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); } @@ -596,6 +626,7 @@ bool ED_view3d_camera_lock_autokey( /** \} */ + /* -------------------------------------------------------------------- */ /** \name Box View Support * @@ -880,22 +911,17 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg * \param fallback_depth_pt: Use this points depth when no depth can be found. */ bool ED_view3d_autodist( - Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, + Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3], const bool alphaoverride, const float fallback_depth_pt[3]) { - bglMats mats; /* ZBuffer depth vars */ float depth_close; - double cent[2], p[3]; int margin_arr[] = {0, 2, 4}; int i; bool depth_ok = false; /* Get Z Depths, needed for perspective, nice for ortho */ - ED_view3d_draw_depth(bmain, scene, ar, v3d, alphaoverride); - - /* call after in case settings have been modified since last drawing, see: T47089 */ - bgl_get_mats(&mats); + ED_view3d_draw_depth(depsgraph, ar, v3d, alphaoverride); /* Attempt with low margin's first */ i = 0; @@ -905,15 +931,10 @@ bool ED_view3d_autodist( } while ((depth_ok == false) && (i < ARRAY_SIZE(margin_arr))); if (depth_ok) { - cent[0] = (double)mval[0] + 0.5; - cent[1] = (double)mval[1] + 0.5; + float centx = (float)mval[0] + 0.5f; + float centy = (float)mval[1] + 0.5f; - if (gluUnProject(cent[0], cent[1], depth_close, - mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) - { - mouse_worldloc[0] = (float)p[0]; - mouse_worldloc[1] = (float)p[1]; - mouse_worldloc[2] = (float)p[2]; + if (ED_view3d_unproject(ar, centx, centy, depth_close, mouse_worldloc)) { return true; } } @@ -927,27 +948,28 @@ bool ED_view3d_autodist( } } -void ED_view3d_autodist_init(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, int mode) +void ED_view3d_autodist_init(Depsgraph *depsgraph, + ARegion *ar, View3D *v3d, int mode) { /* Get Z Depths, needed for perspective, nice for ortho */ switch (mode) { case 0: - ED_view3d_draw_depth(bmain, scene, ar, v3d, true); + ED_view3d_draw_depth(depsgraph, ar, v3d, true); break; case 1: - ED_view3d_draw_depth_gpencil(scene, ar, v3d); + { + Scene *scene = DEG_get_evaluated_scene(depsgraph); + ED_view3d_draw_depth_gpencil(depsgraph, scene, ar, v3d); break; + } } } /* no 4x4 sampling, run #ED_view3d_autodist_init first */ -bool ED_view3d_autodist_simple( - ARegion *ar, const int mval[2], float mouse_worldloc[3], - int margin, float *force_depth) +bool ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], + int margin, float *force_depth) { - bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; - double cent[2], p[3]; /* Get Z Depths, needed for perspective, nice for ortho */ if (force_depth) @@ -958,21 +980,9 @@ bool ED_view3d_autodist_simple( if (depth == FLT_MAX) return false; - cent[0] = (double)mval[0] + 0.5; - cent[1] = (double)mval[1] + 0.5; - - bgl_get_mats(&mats); - - if (!gluUnProject(cent[0], cent[1], depth, - mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) - { - return false; - } - - mouse_worldloc[0] = (float)p[0]; - mouse_worldloc[1] = (float)p[1]; - mouse_worldloc[2] = (float)p[2]; - return true; + float centx = (float)mval[0] + 0.5f; + float centy = (float)mval[1] + 0.5f; + return ED_view3d_unproject(ar, centx, centy, depth, mouse_worldloc); } bool ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth) @@ -1068,6 +1078,7 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius) */ float ED_view3d_radius_to_dist( const View3D *v3d, const ARegion *ar, + const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, const float radius) { @@ -1088,7 +1099,8 @@ float ED_view3d_radius_to_dist( BKE_camera_params_init(¶ms); params.clipsta = v3d->near; params.clipend = v3d->far; - BKE_camera_params_from_object(¶ms, v3d->camera); + Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); + BKE_camera_params_from_object(¶ms, camera_eval); lens = params.lens; sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y); @@ -1279,7 +1291,7 @@ bool ED_view3d_lock(RegionView3D *rv3d) * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat. * \param dist: The view distance from ofs, normally from RegionView3D.dist. */ -void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist) +void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist) { float nmat[3][3]; @@ -1330,7 +1342,7 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c * \param dist: The view distance from ofs to be set, normally from RegionView3D.dist. * \param lens: The view lens angle set for cameras and lamps, normally from View3D.lens. */ -void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens) +void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens) { ED_view3d_from_m4(ob->obmat, ofs, quat, dist); @@ -1345,16 +1357,19 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, /** * Set the object transformation from RegionView3D members. + * \param depsgraph: The depsgraph to get the evaluated object parent for the transformation calculation. * \param ob: The object which has the transformation assigned. * \param ofs: The view offset, normally from RegionView3D.ofs. * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat. * \param dist: The view distance from ofs, normally from RegionView3D.dist. */ -void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist) +void ED_view3d_to_object(const Depsgraph *depsgraph, Object *ob, const float ofs[3], const float quat[4], const float dist) { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - BKE_object_apply_mat4(ob, mat, true, true); + + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + BKE_object_apply_mat4_ex(ob, mat, ob_eval->parent, ob_eval->parentinv, true); } /** \} */ @@ -1380,7 +1395,7 @@ float ED_view3d_depth_read_cached(const ViewContext *vc, const int mval[2]) } bool ED_view3d_depth_read_cached_normal( - const ViewContext *vc, const bglMats *mats, const int mval[2], + const ViewContext *vc, const int mval[2], float r_normal[3]) { /* Note: we could support passing in a radius. @@ -1399,7 +1414,7 @@ bool ED_view3d_depth_read_cached_normal( const double depth = (double)ED_view3d_depth_read_cached(vc, mval_ofs); if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) { - if (ED_view3d_depth_unproject(ar, mats, mval_ofs, depth, coords[i])) { + if (ED_view3d_depth_unproject(ar, mval_ofs, depth, coords[i])) { depths_valid[i] = true; } } @@ -1441,21 +1456,13 @@ bool ED_view3d_depth_read_cached_normal( } bool ED_view3d_depth_unproject( - const ARegion *ar, const bglMats *mats, + const ARegion *ar, const int mval[2], const double depth, float r_location_world[3]) { - double p[3]; - if (gluUnProject( - (double)ar->winrct.xmin + mval[0] + 0.5, - (double)ar->winrct.ymin + mval[1] + 0.5, - depth, mats->modelview, mats->projection, (const GLint *)mats->viewport, - &p[0], &p[1], &p[2])) - { - copy_v3fl_v3db(r_location_world, p); - return true; - } - return false; + float centx = (float)mval[0] + 0.5f; + float centy = (float)mval[1] + 0.5f; + return ED_view3d_unproject(ar, centx, centy, depth, r_location_world); } void ED_view3d_depth_tag_update(RegionView3D *rv3d) @@ -1465,46 +1472,3 @@ void ED_view3d_depth_tag_update(RegionView3D *rv3d) } /** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Background Image Utilities - * \{ */ - -BGpic *ED_view3d_background_image_new(View3D *v3d) -{ - BGpic *bgpic = MEM_callocN(sizeof(BGpic), "Background Image"); - - bgpic->rotation = 0.0f; - bgpic->size = 5.0f; - bgpic->blend = 0.5f; - bgpic->iuser.fie_ima = 2; - bgpic->iuser.ok = 1; - bgpic->view = 0; /* 0 for all */ - bgpic->flag |= V3D_BGPIC_EXPANDED; - - BLI_addtail(&v3d->bgpicbase, bgpic); - - return bgpic; -} - -void ED_view3d_background_image_remove(View3D *v3d, BGpic *bgpic) -{ - BLI_remlink(&v3d->bgpicbase, bgpic); - - MEM_freeN(bgpic); -} - -void ED_view3d_background_image_clear(View3D *v3d) -{ - BGpic *bgpic = v3d->bgpicbase.first; - - while (bgpic) { - BGpic *next_bgpic = bgpic->next; - - ED_view3d_background_image_remove(v3d, bgpic); - - bgpic = next_bgpic; - } -} - -/** \} */ |