fix for asserts added in own recent commit with more strict type-checking
authorCampbell Barton <ideasman42@gmail.com>
Tue, 27 Nov 2012 02:34:40 +0000 (02:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 27 Nov 2012 02:34:40 +0000 (02:34 +0000)
- BMO_slot_copy now only copies compatible elements.

other minor changes
- don't use text.format(...), convention for UI scripts is C style string formatting.
- rename bmo_edgenet_prepare --> bmo_edgenet_prepare_exec
- float/double warning in bevel.

release/scripts/startup/bl_ui/properties_particle.py
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/intern/bmesh_operator_api.h
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_operators_private.h
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/editors/mesh/editmesh_utils.c

index 6fcd56fb99ead5de2739796d9b3bbdcb4b4e134a..3f672d2a9771521f6fc2d2af3c0a0e6446b3f0d7 100644 (file)
@@ -148,7 +148,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
             #row.label(text="Render")
 
             if part.is_fluid:
-                layout.label(text="{} fluid particles for this frame".format(str(part.count)))
+                layout.label(text="%d fluid particles for this frame" % part.count)
                 return
 
             row = col.row()
index f14fac64ba3ad7a7b9e4e2c91e89512f1f9727cc..64b3ce66ca9e6cf5c18097b293234c91e732d2d4 100644 (file)
@@ -569,7 +569,7 @@ static BMOpDefine bmo_edgenet_prepare_def = {
        {{"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},  /* new edges */
         {{'\0'}},
        },
-       bmo_edgenet_prepare,
+       bmo_edgenet_prepare_exec,
        0,
 };
 
index 245a53ebed2408bd75fb7f1ac6022e08cfd4e2bd..1bb83a12e4800d3eb1b954fcadd9b3322c21272d 100644 (file)
@@ -136,8 +136,8 @@ typedef enum eBMOpSlotSubType_Ptr {
 } eBMOpSlotSubType_Ptr;
 
 typedef union eBMOpSlotSubType_Union {
-       eBMOpSlotSubType_Map elem;
-       eBMOpSlotSubType_Map ptr;
+       eBMOpSlotSubType_Elem elem;
+       eBMOpSlotSubType_Ptr ptr;
        eBMOpSlotSubType_Map map;
 } eBMOpSlotSubType_Union;
 
index f1bf4fd4d373f99059c1613e686e1ab39aff8352..20fffe71636ef9ad89926e4af6898058bc57cb38 100644 (file)
@@ -288,9 +288,49 @@ void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_n
                slot_dst->data.buf = NULL;
                slot_dst->len = slot_src->len;
                if (slot_dst->len) {
-                       const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type] * slot_dst->len;
-                       slot_dst->data.buf = BLI_memarena_alloc(arena_dst, slot_alloc_size);
-                       memcpy(slot_dst->data.buf, slot_src->data.buf, slot_alloc_size);
+                       /* check dest has all flags enabled that the source has */
+                       const eBMOpSlotSubType_Elem src_elem_flag = (slot_src->slot_subtype.elem & BM_ALL_NOLOOP);
+                       const eBMOpSlotSubType_Elem dst_elem_flag = (slot_dst->slot_subtype.elem & BM_ALL_NOLOOP);
+
+                       if ((src_elem_flag | dst_elem_flag) == dst_elem_flag) {
+                               /* pass */
+                       }
+                       else {
+                               /* check types */
+                               const unsigned int tot = slot_src->len;
+                               unsigned int i;
+                               unsigned int out = 0;
+                               BMElem **ele_src = (BMElem **)slot_src->data.buf;
+                               for (i = 0; i < tot; i++, ele_src++) {
+                                       if ((*ele_src)->head.htype & dst_elem_flag) {
+                                               out++;
+                                       }
+                               }
+                               if (out != tot) {
+                                       slot_dst->len = out;
+                               }
+                       }
+
+                       if (slot_dst->len) {
+                               const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type] * slot_dst->len;
+                               slot_dst->data.buf = BLI_memarena_alloc(arena_dst, slot_alloc_size);
+                               if (slot_src->len == slot_dst->len) {
+                                       memcpy(slot_dst->data.buf, slot_src->data.buf, slot_alloc_size);
+                               }
+                               else {
+                                       /* only copy compatible elements */
+                                       const unsigned int tot = slot_src->len;
+                                       unsigned int i;
+                                       BMElem **ele_src = (BMElem **)slot_src->data.buf;
+                                       BMElem **ele_dst = (BMElem **)slot_dst->data.buf;
+                                       for (i = 0; i < tot; i++, ele_src++) {
+                                               if ((*ele_src)->head.htype & dst_elem_flag) {
+                                                       *ele_dst = *ele_src;
+                                                       ele_dst++;
+                                               }
+                                       }
+                               }
+                       }
                }
        }
        else if (slot_dst->slot_type == BMO_OP_SLOT_MAPPING) {
index 65c9cf0c421e20c960e935b17be34adbc5e99361..9175af1c822e1eb92e67607c3aba16a8850edfc0 100644 (file)
@@ -61,7 +61,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op);
 void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op);
 void bmo_duplicate_exec(BMesh *bm, BMOperator *op);
 void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op);
-void bmo_edgenet_prepare(BMesh *bm, BMOperator *op);
+void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op);
 void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op);
 void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op);
 void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op);
index 987aa8cdf9933bc660300d15db42e4984ec56792..a6bbd0927608534995db0a710c0cbc0419a5e207 100644 (file)
@@ -1098,7 +1098,7 @@ static BMEdge *edge_next(BMesh *bm, BMEdge *e)
        return NULL;
 }
 
-void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
+void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
 {
        BMOIter siter;
        BMEdge *e;
index e4509dd0fa94d1967a4c5f5a1944d34ba2827eab..0d16d0af1145a5506795c4e220740cfd362455c9 100644 (file)
@@ -663,7 +663,7 @@ static void get_point_on_round_edge(EdgeHalf *e, int k,
 
        sub_v3_v3v3(va_vmid, vmid, va);
        sub_v3_v3v3(vb_vmid, vmid, vb);
-       if (fabs(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) > 100.f *(float)BEVEL_EPSILON) {
+       if (fabsf(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) > 100.f *(float)BEVEL_EPSILON) {
                sub_v3_v3v3(vo, va, vb_vmid);
                cross_v3_v3v3(vddir, vb_vmid, va_vmid);
                normalize_v3(vddir);
index 639e766826632e4701e460a71be32f07a1501e36..2cf63586142e3fa6eaf603290d3355b5044777e7 100644 (file)
@@ -265,9 +265,11 @@ int EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...)
 
 int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...)
 {
+       BMOpSlot *slot_select_out;
        BMesh *bm = em->bm;
        BMOperator bmop;
        va_list list;
+       char hflag;
 
        va_start(list, fmt);
 
@@ -283,9 +285,12 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_
 
        BMO_op_exec(bm, &bmop);
 
+       slot_select_out = BMO_slot_get(bmop.slots_out, select_slot_out);
+       hflag = slot_select_out->slot_subtype.elem & BM_ALL_NOLOOP;
+
        BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
 
-       BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, BM_ALL_NOLOOP, BM_ELEM_SELECT, TRUE);
+       BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, hflag, BM_ELEM_SELECT, TRUE);
 
        va_end(list);
        return EDBM_op_finish(em, &bmop, op, TRUE);