svn merge ^/trunk/blender -r50132:50138
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Aug 2012 06:32:51 +0000 (06:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Aug 2012 06:32:51 +0000 (06:32 +0000)
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_interp.h
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/operators/bmo_connect.c
source/blender/compositor/operations/COM_InpaintOperation.cpp
source/blender/editors/mesh/editmesh_tools.c
source/blender/imbuf/intern/dds/CMakeLists.txt
source/blender/imbuf/intern/dds/SConscript
source/blender/imbuf/intern/dds/dds_api.cpp

index 9453932b684b88c22d75a6fcc7810318ed1345bc..164885016519019975fb0b962a50df5c70d45bb8 100644 (file)
 #include "bmesh.h"
 #include "intern/bmesh_private.h"
 
-/**
- * \brief Data, Interp From Verts
- *
- * Interpolates per-vertex data from two sources to a target.
- */
-void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac)
+/* edge and vertex share, currently theres no need to have different logic */
+static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMElem *ele_dst, const float fac)
 {
-       if (v1->head.data && v2->head.data) {
+       if (ele1->head.data && ele2->head.data) {
                /* first see if we can avoid interpolation */
                if (fac <= 0.0f) {
-                       if (v1 == v) {
+                       if (ele1 == ele_dst) {
                                /* do nothing */
                        }
                        else {
-                               CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
-                               CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, v1->head.data, &v->head.data);
+                               CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data);
+                               CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele1->head.data, &ele_dst->head.data);
                        }
                }
                else if (fac >= 1.0f) {
-                       if (v2 == v) {
+                       if (ele2 == ele_dst) {
                                /* do nothing */
                        }
                        else {
-                               CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
-                               CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, v2->head.data, &v->head.data);
+                               CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data);
+                               CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele2->head.data, &ele_dst->head.data);
                        }
                }
                else {
                        void *src[2];
                        float w[2];
 
-                       src[0] = v1->head.data;
-                       src[1] = v2->head.data;
+                       src[0] = ele1->head.data;
+                       src[1] = ele2->head.data;
                        w[0] = 1.0f - fac;
                        w[1] = fac;
-                       CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->head.data);
+                       CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, ele_dst->head.data);
                }
        }
 }
 
+/**
+ * \brief Data, Interp From Verts
+ *
+ * Interpolates per-vertex data from two sources to a target.
+ *
+ * \note This is an exact match to #BM_data_interp_from_edges
+ */
+void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac)
+{
+       bm_data_interp_from_elem(bm, (BMElem *)v1, (BMElem *)v2, (BMElem *)v, fac);
+}
+
+/**
+ * \brief Data, Interp From Edges
+ *
+ * Interpolates per-edge data from two sources to a target.
+ *
+ * \note This is an exact match to #BM_data_interp_from_verts
+ */
+void BM_data_interp_from_edges(BMesh *bm, BMEdge *e1, BMEdge *e2, BMEdge *e, const float fac)
+{
+       bm_data_interp_from_elem(bm, (BMElem *)e1, (BMElem *)e2, (BMElem *)e, fac);
+}
+
 /**
  * \brief Data Vert Average
  *
index 3380a3e6b1b7fe0f60aa19dc2e2573539082268c..8be963f579828dca8241e9611cb568d3b2c89277 100644 (file)
@@ -31,6 +31,7 @@ void  BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source);
 void  BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source);
 
 void  BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac);
+void  BM_data_interp_from_edges(BMesh *bm, BMEdge *e1, BMEdge *e2, BMEdge *e, const float fac);
 void  BM_data_interp_face_vert_edge(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, BMEdge *e1, const float fac);
 void  BM_data_layer_add(BMesh *em, CustomData *data, int type);
 void  BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name);
index eacee8e12ad644ca9963ff0aacee52c3d86795f3..986c84b06399074eb65c349c934d7b29a0d628d2 100644 (file)
@@ -422,6 +422,8 @@ static BMOpDefine bmo_bridge_loops_def = {
        "bridge_loops",
        {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */
         {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
+        {BMO_OP_SLOT_BOOL,        "use_merge"},
+        {BMO_OP_SLOT_FLT,         "merge_factor"},
         {0, /* null-terminating sentinel */}},
        bmo_bridge_loops_exec,
        0,
index a9599a4858937b483b8830c9560a5168e9bfb0e2..c9a0d74de3836bf2a675a40117a4f7f379e5e656 100644 (file)
@@ -223,6 +223,10 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
        BMEdge *e, *nexte;
        int c = 0, cl1 = 0, cl2 = 0;
 
+       /* merge-bridge support */
+       const int   use_merge    = BMO_slot_bool_get(op, "use_merge");
+       const float merge_factor = BMO_slot_float_get(op, "merge_factor");
+
        BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
 
        BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
@@ -423,59 +427,101 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                        }
                }
                
-               /* Generate the bridge quads */
-               for (i = 0; i < BLI_array_count(ee1) && i < BLI_array_count(ee2); i++) {
-                       BMFace *f;
-
-                       BMLoop *l_1 = NULL;
-                       BMLoop *l_2 = NULL;
-                       BMLoop *l_1_next = NULL;
-                       BMLoop *l_2_next = NULL;
-                       BMLoop *l_iter;
-                       BMFace *f_example;
-
-                       int i1, i1next, i2, i2next;
-
-                       i1 = clamp_index(i * dir1 + starti, lenv1);
-                       i1next = clamp_index((i + 1) * dir1 + starti, lenv1);
-                       i2 = i;
-                       i2next = clamp_index(i + 1, lenv2);
-
-                       if (vv1[i1] == vv1[i1next]) {
-                               continue;
-                       }
-
-                       if (wdir < 0) {
-                               SWAP(int, i1, i1next);
-                               SWAP(int, i2, i2next);
+               /* merge loops of bridge faces */
+               if (use_merge) {
+                       /* at the moment these will be the same */
+                       const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2));
+                       const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2));
+
+                       if (merge_factor <= 0.0f) {
+                               /* 2 --> 1 */
+                               for (i = 0; i < vert_len; i++) {
+                                       BM_vert_splice(bm, vv2[i], vv1[i]);
+                               }
+                               for (i = 0; i < edge_len; i++) {
+                                       BM_edge_splice(bm, ee2[i], ee1[i]);
+                               }
                        }
-
-                       /* get loop data - before making the face */
-                       bm_vert_loop_pair(bm, vv1[i1], vv2[i2], &l_1, &l_2);
-                       bm_vert_loop_pair(bm, vv1[i1next], vv2[i2next], &l_1_next, &l_2_next);
-                       /* copy if loop data if its is missing on one ring */
-                       if (l_1 && l_1_next == NULL) l_1_next = l_1;
-                       if (l_1_next && l_1 == NULL) l_1 = l_1_next;
-                       if (l_2 && l_2_next == NULL) l_2_next = l_2;
-                       if (l_2_next && l_2 == NULL) l_2 = l_2_next;
-                       f_example = l_1 ? l_1->f : (l_2 ? l_2->f : NULL);
-
-                       f = BM_face_create_quad_tri(bm,
-                                                   vv1[i1],
-                                                   vv2[i2],
-                                                   vv2[i2next],
-                                                   vv1[i1next],
-                                                   f_example, TRUE);
-                       if (!f || f->len != 4) {
-                               fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__);
+                       else if (merge_factor >= 1.0f) {
+                               /* 1 --> 2 */
+                               for (i = 0; i < vert_len; i++) {
+                                       BM_vert_splice(bm, vv1[i], vv2[i]);
+                               }
+                               for (i = 0; i < edge_len; i++) {
+                                       BM_edge_splice(bm, ee1[i], ee2[i]);
+                               }
                        }
                        else {
-                               l_iter = BM_FACE_FIRST_LOOP(f);
+                               /* mid factor, be tricky */
+                               /* 1 --> 2 */
+                               for (i = 0; i < vert_len; i++) {
+                                       BM_data_interp_from_verts(bm, vv1[i], vv2[i], vv2[i], merge_factor);
+                                       interp_v3_v3v3(vv2[i]->co, vv1[i]->co, vv2[i]->co, merge_factor);
+                                       BM_elem_flag_merge(vv1[i], vv2[i]);
+                                       BM_vert_splice(bm, vv1[i], vv2[i]);
+                               }
+                               for (i = 0; i < edge_len; i++) {
+                                       BM_data_interp_from_edges(bm, ee1[i], ee2[i], ee2[i], merge_factor);
+                                       BM_elem_flag_merge(ee1[i], ee2[i]);
+                                       BM_edge_splice(bm, ee1[i], ee2[i]);
+                               }
+                       }
+               }
+               else {
+                       /* Generate the bridge quads */
+                       for (i = 0; i < BLI_array_count(ee1) && i < BLI_array_count(ee2); i++) {
+                               BMFace *f;
+
+                               BMLoop *l_1 = NULL;
+                               BMLoop *l_2 = NULL;
+                               BMLoop *l_1_next = NULL;
+                               BMLoop *l_2_next = NULL;
+                               BMLoop *l_iter;
+                               BMFace *f_example;
+
+                               int i1, i1next, i2, i2next;
+
+                               i1 = clamp_index(i * dir1 + starti, lenv1);
+                               i1next = clamp_index((i + 1) * dir1 + starti, lenv1);
+                               i2 = i;
+                               i2next = clamp_index(i + 1, lenv2);
+
+                               if (vv1[i1] == vv1[i1next]) {
+                                       continue;
+                               }
 
-                               if (l_1)      BM_elem_attrs_copy(bm, bm, l_1,      l_iter); l_iter = l_iter->next;
-                               if (l_2)      BM_elem_attrs_copy(bm, bm, l_2,      l_iter); l_iter = l_iter->next;
-                               if (l_2_next) BM_elem_attrs_copy(bm, bm, l_2_next, l_iter); l_iter = l_iter->next;
-                               if (l_1_next) BM_elem_attrs_copy(bm, bm, l_1_next, l_iter);
+                               if (wdir < 0) {
+                                       SWAP(int, i1, i1next);
+                                       SWAP(int, i2, i2next);
+                               }
+
+                               /* get loop data - before making the face */
+                               bm_vert_loop_pair(bm, vv1[i1], vv2[i2], &l_1, &l_2);
+                               bm_vert_loop_pair(bm, vv1[i1next], vv2[i2next], &l_1_next, &l_2_next);
+                               /* copy if loop data if its is missing on one ring */
+                               if (l_1 && l_1_next == NULL) l_1_next = l_1;
+                               if (l_1_next && l_1 == NULL) l_1 = l_1_next;
+                               if (l_2 && l_2_next == NULL) l_2_next = l_2;
+                               if (l_2_next && l_2 == NULL) l_2 = l_2_next;
+                               f_example = l_1 ? l_1->f : (l_2 ? l_2->f : NULL);
+
+                               f = BM_face_create_quad_tri(bm,
+                                                           vv1[i1],
+                                                           vv2[i2],
+                                                           vv2[i2next],
+                                                           vv1[i1next],
+                                                           f_example, TRUE);
+                               if (!f || f->len != 4) {
+                                       fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__);
+                               }
+                               else {
+                                       l_iter = BM_FACE_FIRST_LOOP(f);
+
+                                       if (l_1)      BM_elem_attrs_copy(bm, bm, l_1,      l_iter); l_iter = l_iter->next;
+                                       if (l_2)      BM_elem_attrs_copy(bm, bm, l_2,      l_iter); l_iter = l_iter->next;
+                                       if (l_2_next) BM_elem_attrs_copy(bm, bm, l_2_next, l_iter); l_iter = l_iter->next;
+                                       if (l_1_next) BM_elem_attrs_copy(bm, bm, l_1_next, l_iter);
+                               }
                        }
                }
        }
index 6ae42b36a7ca705a3ab79f69d0c4568787cb828b..70d4d987c81fb23685c2cdb36994517a354fec3e 100644 (file)
@@ -182,6 +182,7 @@ void InpaintSimpleOperation::pix_step(int x, int y)
 
        for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
+                       /* changing to both != 0 gives dithering artifacts */
                        if (dx != 0 || dy != 0) {
                                int x_ofs = x + dx;
                                int y_ofs = y + dy;
@@ -213,8 +214,6 @@ void InpaintSimpleOperation::pix_step(int x, int y)
                interp_v3_v3v3(output, pix, output, output[3]);
                output[3] = 1.0f;
        }
-
-       this->get_pixel(x, y)[3] = 1.0f;
 }
 
 void *InpaintSimpleOperation::initializeTileData(rcti *rect)
index 3945c1bb57a32b871f89170800870cf913cfce18..6bd2ac75226b6446e2880e8f29818d1480318803 100644 (file)
@@ -4804,8 +4804,12 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BMEdit_FromObject(obedit);
        
-       if (!EDBM_op_callf(em, op, "bridge_loops edges=%he", BM_ELEM_SELECT))
+       if (!EDBM_op_callf(em, op,
+                          "bridge_loops edges=%he use_merge=%b merge_factor=%f",
+                          BM_ELEM_SELECT, RNA_boolean_get(op->ptr, "use_merge"), RNA_float_get(op->ptr, "merge_factor")))
+       {
                return OPERATOR_CANCELLED;
+       }
        
        EDBM_update_generic(C, em, TRUE);
 
@@ -4827,6 +4831,9 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
        
        RNA_def_boolean(ot->srna, "inside", 0, "Inside", "");
+
+       RNA_def_boolean(ot->srna, "use_merge", FALSE, "Merge", "Merge rather than creating faces");
+       RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f);
 }
 
 typedef struct {
index ae5f1ca9d09778f5229c6b381e43fcafde3f68df..e514b7ab6f90305ff7aa77cabb8fbc2d89e33af1 100644 (file)
@@ -31,6 +31,7 @@ set(INC
        ../../../blenlib
        ../../../makesdna
        ../../../../../intern/guardedalloc
+       ../../../../../intern/utfconv
 )
 
 set(INC_SYS
index 918ae7b530baab3c77ed2a5833f97338ba9155d6..4245f5001b9825fac0c71f6c8ed2a2ee4d034c10 100644 (file)
@@ -11,7 +11,8 @@ incs = ['.',
     '../../../blenkernel',
     '../../../blenlib',
     'intern/include',
-    '#/intern/guardedalloc']
+    '#/intern/guardedalloc',
+    '#/intern/utfconv']
 
 
 defs = ['WITH_DDS']
index 1aaeb4766e1f7b7aa0fc905f6264990fa8f6ea8a..71313d4438f9e3a6a39109d8045bb18d78e10323 100644 (file)
@@ -32,7 +32,7 @@
 #include <stdio.h> // printf
 #include <fstream>
 
-#ifdef WIN32
+#if defined (WIN32) && !defined(FREE_WINDOWS)
 #include "utfconv.h"
 #endif
 
@@ -54,7 +54,7 @@ int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags)
        /* open file for writing */
        std::ofstream fildes;
 
-#ifdef WIN32
+#if defined (WIN32) && !defined(FREE_WINDOWS)
        wchar_t *wname = alloc_utf16_from_8(name, 0);
        fildes.open(wname);
        free(wname);