dont display image sequences outside the frame range in the 3D viewport.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 14:04:39 +0000 (14:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 14:04:39 +0000 (14:04 +0000)
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_image_types.h

index 699eb0a9f02fea5a8f5ff490cfcc551c45abdd55..909ed471081f995913369af92edfc4ae5c48ab0b 100644 (file)
@@ -157,7 +157,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf);
 /* called on frame change or before render */
 void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
 void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
-int  BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr);
+int  BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range);
 void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path); 
 
 /* sets index offset for multilayer files */
index beaf8f719e3587afe1fbdc16c7e4f0f4c84e7c82..65747baa3232c2672701663127b93db84b9f6013 100644 (file)
@@ -2784,10 +2784,14 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
        return BKE_image_acquire_ibuf(ima, iuser, NULL);
 }
 
-int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr)
+int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range)
 {
        const int len = (iuser->fie_ima * iuser->frames) / 2;
 
+       if (r_is_in_range) {
+               *r_is_in_range = FALSE;
+       }
+
        if (len == 0) {
                return 0;
        }
@@ -2800,10 +2804,23 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr)
                        cfra = ((cfra) % len);
                        if (cfra < 0) cfra += len;
                        if (cfra == 0) cfra = len;
+
+                       if (r_is_in_range) {
+                               *r_is_in_range = TRUE;
+                       }
                }
 
-               if (cfra < 0) cfra = 0;
-               else if (cfra > len) cfra = len;
+               if (cfra < 0) {
+                       cfra = 0;
+               }
+               else if (cfra > len) {
+                       cfra = len;
+               }
+               else {
+                       if (r_is_in_range) {
+                               *r_is_in_range = TRUE;
+                       }
+               }
 
                /* convert current frame to current field */
                cfra = 2 * (cfra);
@@ -2827,7 +2844,15 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr)
 void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
 {
        if (iuser) {
-               const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr);
+               short is_in_range;
+               const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr, &is_in_range);
+
+               if (is_in_range) {
+                       iuser->flag |= IMA_USER_FRAME_IN_RANGE;
+               }
+               else {
+                       iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
+               }
 
                /* allows image users to handle redraws */
                if (iuser->flag & IMA_ANIM_ALWAYS)
index 8c77e8bec65e4473c62ada1660472e11f80a5516..7191284bc5bd723ce00da8f30d0abc9887d6a2f4 100644 (file)
@@ -2892,11 +2892,9 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase, wmO
 static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOperator *wmop)
 {
        int i;
-       BMVert *v;
        BMEdge *e;
        BMVert *v_seed;
        BMWalker walker;
-       BMIter iter;
        int result = FALSE;
        Object *obedit = editbase->object;
        BMEditMesh *em = BMEdit_FromObject(obedit);
@@ -2913,11 +2911,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper
         * original mesh.*/
        for (i = 0; i < max_iter; i++) {
                /* Get a seed vertex to start the walk */
-               v_seed = NULL;
-               BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
-                       v_seed = v;
-                       break;
-               }
+               v_seed = BM_iter_at_index(bm, BM_VERTS_OF_MESH, NULL, 0);
 
                /* No vertices available, can't do anything */
                if (v_seed == NULL) {
index aa596b8b6358cdea13d19404c44fbef5bef51515..92c339d767284219778b7dac392ad04da2b64fdf 100644 (file)
@@ -148,7 +148,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
        /* the frame number, even if we cant */
        if (ima->source == IMA_SRC_SEQUENCE) {
                /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
-               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
+               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
                ofs += sprintf(str + ofs, IFACE_(", Frame: %d"), framenr);
        }
 
index a4fb4d7dfeef6903241f1c395f57c649da5befd7..daab0ce0f5f91083e7cd1133d5cff01a040170ef 100644 (file)
@@ -1213,7 +1213,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
                Scene *scene = CTX_data_scene(C);
                ImageUser *iuser = iuserptr->data;
                char numstr[32];
-               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
+               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
                BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
                uiItemL(layout, numstr, ICON_NONE);
        }
index 2d4fbb90ae11c1a0c19d606bcbd945e7feb84256..e6ea42aa5bac0edd2f58bf79d8341846c80e8a4e 100644 (file)
@@ -1561,7 +1561,12 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
                                if (ima == NULL)
                                        continue;
                                BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0);
-                               ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
+                               if (ima->source == IMA_SRC_SEQUENCE && !(bgpic->iuser.flag & IMA_USER_FRAME_IN_RANGE)) {
+                                       ibuf = NULL; /* frame is out of range, dont show */
+                               }
+                               else {
+                                       ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
+                               }
 
                                image_aspect[0] = ima->aspx;
                                image_aspect[1] = ima->aspx;
index f6c4822bb558bdb6fd2d84fd05b7a4738f851cbc..4a4b21017db7e19b150e07c60f2f158df2fb6981 100644 (file)
@@ -122,6 +122,7 @@ typedef struct Image {
 #define IMA_OLD_PREMUL         128
 #define IMA_CM_PREDIVIDE       256
 #define IMA_USED_FOR_RENDER    512
+#define IMA_USER_FRAME_IN_RANGE        1024 /* for image user, but these flags are mixed */
 
 /* Image.tpageflag */
 #define IMA_TILES                      1