svn merge ^/trunk/blender -r46380:HEAD
authorOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Tue, 8 May 2012 00:22:02 +0000 (00:22 +0000)
committerOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Tue, 8 May 2012 00:22:02 +0000 (00:22 +0000)
1  2 
source/blender/editors/mesh/editmesh_tools.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/windowmanager/intern/wm_operators.c

index e689c201b21ab7c77e3f14927e10c19fc2195207,2f317ed87c2b1632a98868871133c6ea2eed3989..eccc1e5ed1a40e5c145ce983d7a11a3e5d0d842a
@@@ -89,6 -89,7 +89,6 @@@ static int edbm_subdivide_exec(bContex
        int cuts = RNA_int_get(op->ptr, "number_cuts");
        float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness");
        float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f;
 -      float along_normal = RNA_float_get(op->ptr, "fractal_along_normal");
  
        if (RNA_boolean_get(op->ptr, "quadtri") && 
            RNA_enum_get(op->ptr, "quadcorner") == SUBD_STRAIGHT_CUT)
@@@ -97,7 -98,7 +97,7 @@@
        }
        
        BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT,
 -                         smooth, fractal, along_normal,
 +                         smooth, fractal,
                           cuts,
                           SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"),
                           RNA_boolean_get(op->ptr, "quadtri"), TRUE,
@@@ -145,6 -146,7 +145,6 @@@ void MESH_OT_subdivide(wmOperatorType *
                     "Quad Corner Type", "How to subdivide quad corners (anything other than Straight Cut will prevent ngons)");
  
        RNA_def_float(ot->srna, "fractal", 0.0f, 0.0f, FLT_MAX, "Fractal", "Fractal randomness factor", 0.0f, 1000.0f);
 -      RNA_def_float(ot->srna, "fractal_along_normal", 0.0f, 0.0f, 1.0f, "Along Normal", "Apply fractal displacement along normal only", 0.0f, 1.0f);
        RNA_def_int(ot->srna, "seed", 0, 0, 10000, "Random Seed", "Seed for the random number generator", 0, 50);
  }
  
@@@ -614,7 -616,7 +614,7 @@@ static int edbm_extrude_faces_exec(bCon
  
        edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor);
        
-       WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
+       EDBM_update_generic(C, em, TRUE);
        
        return OPERATOR_FINISHED;
  }
@@@ -2347,7 -2349,7 +2347,7 @@@ static int edbm_select_axis_exec(bConte
                        if (!BM_elem_flag_test(ev, BM_ELEM_HIDDEN)) {
                                switch (mode) {
                                        case -1: /* aligned */
 -                                              if (fabsf(ev->co[axis] - value) < limit)
 +                                              if (fabs(ev->co[axis] - value) < limit)
                                                        BM_vert_select_set(em->bm, ev, TRUE);
                                                break;
                                        case 0: /* neg */
@@@ -2594,21 -2596,21 +2594,21 @@@ static float bm_edge_seg_isect(BMEdge *
                                m1 = MAXSLOPE;
                                b1 = x12;
                        }
 -                      x2max = MAX2(x21, x22) + 0.001f; /* prevent missed edges   */
 -                      x2min = MIN2(x21, x22) - 0.001f; /* due to round off error */
 -                      y2max = MAX2(y21, y22) + 0.001f;
 -                      y2min = MIN2(y21, y22) - 0.001f;
 +                      x2max = MAX2(x21, x22) + 0.001; /* prevent missed edges   */
 +                      x2min = MIN2(x21, x22) - 0.001; /* due to round off error */
 +                      y2max = MAX2(y21, y22) + 0.001;
 +                      y2min = MIN2(y21, y22) - 0.001;
                        
                        /* Found an intersect,  calc intersect point */
                        if (m1 == m2) { /* co-incident lines */
                                /* cut at 50% of overlap area */
                                x1max = MAX2(x11, x12);
                                x1min = MIN2(x11, x12);
 -                              xi = (MIN2(x2max, x1max) + MAX2(x2min, x1min)) / 2.0f;
 +                              xi = (MIN2(x2max, x1max) + MAX2(x2min, x1min)) / 2.0;
                                
                                y1max = MAX2(y11, y12);
                                y1min = MIN2(y11, y12);
 -                              yi = (MIN2(y2max, y1max) + MAX2(y2min, y1min)) / 2.0f;
 +                              yi = (MIN2(y2max, y1max) + MAX2(y2min, y1min)) / 2.0;
                        }
                        else if (m2 == MAXSLOPE) {
                                xi = x22;
@@@ -3207,11 -3209,45 +3207,11 @@@ static int edbm_dissolve_limited_exec(b
  {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BMEdit_FromObject(obedit);
 -      BMesh *bm = em->bm;
        float angle_limit = RNA_float_get(op->ptr, "angle_limit");
  
 -      char dissolve_flag;
 -
 -      if (em->selectmode == SCE_SELECT_FACE) {
 -              /* flush selection to tags and untag edges/verts with partially selected faces */
 -              BMIter iter;
 -              BMIter liter;
 -
 -              BMElem *ele;
 -              BMFace *f;
 -              BMLoop *l;
 -
 -              BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
 -                      BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
 -              }
 -              BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
 -                      BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT));
 -              }
 -
 -              BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
 -                      if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
 -                              BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
 -                                      BM_elem_flag_disable(l->v, BM_ELEM_TAG);
 -                                      BM_elem_flag_disable(l->e, BM_ELEM_TAG);
 -                              }
 -                      }
 -              }
 -
 -              dissolve_flag = BM_ELEM_TAG;
 -      }
 -      else {
 -              dissolve_flag = BM_ELEM_SELECT;
 -      }
 -
        if (!EDBM_op_callf(em, op,
                           "dissolve_limit edges=%he verts=%hv angle_limit=%f",
 -                         dissolve_flag, dissolve_flag, angle_limit))
 +                         BM_ELEM_SELECT, BM_ELEM_SELECT, angle_limit))
        {
                return OPERATOR_CANCELLED;
        }
@@@ -4220,7 -4256,7 +4220,7 @@@ static int edbm_noise_exec(bContext *C
  
        if (tex->type == TEX_STUCCI) {
                float b2, vec[3];
 -              float ofs = tex->turbul / 200.0f;
 +              float ofs = tex->turbul / 200.0;
                BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
                        if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
                                b2 = BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]);
@@@ -4307,7 -4343,7 +4307,7 @@@ static int edbm_bevel_exec(bContext *C
                w[i] = s;
                ftot += s;
  
 -              df *= 2.0f;
 +              df *= 2.0;
        }
  
        mul_vn_fl(w, recursion, 1.0f / (float)ftot);
index 7a32e7d208406c82c90b4cbf794d0ec50515fa74,b45304a315fd8084063f2220f8f6a50f0187dd98..e3e873deabd12ff3da8010f84892ee4ec896dce0
@@@ -451,8 -451,6 +451,6 @@@ static DerivedMesh *applyModifier(Modif
                /* same as EM_solidify() in editmesh_lib.c */
                float *vert_angles = MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */
                float *vert_accum = vert_angles + numVerts;
-               float *face_angles = NULL;
-               BLI_array_staticdeclare(face_angles, 16); /* BM_NGON_STACK_SIZE */
                int j, vidx;
  
                face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL);
                                mesh_calc_poly_normal(mp, &mloop[mp->loopstart], mvert, face_nors[i]);
                        
                        /* just added, calc the normal */
-                       BLI_array_empty(face_angles);
-                       BLI_array_reserve(face_angles, mp->totloop);
                        for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) {
                                MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j);
                                MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j);
  
                                float e1[3], e2[3];
+                               float angle;
  
+                               /* TODO - we could speed this up by _not_ normalizing both verts each time
+                                * and always re-usingthe last vector. */
                                sub_v3_v3v3(e1, mvert[ml_next->v].co, mvert[ml->v].co);
                                sub_v3_v3v3(e2, mvert[ml_prev->v].co, mvert[ml->v].co);
-                               face_angles[j] = (float)M_PI - angle_v3v3(e1, e2);
-                       }
-                       
-                       for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) {
+                               angle = (float)M_PI - angle_v3v3(e1, e2);
+                               if (angle < FLT_EPSILON) {
+                                       angle = FLT_EPSILON;
+                               }
                                vidx = ml->v;
-                               vert_accum[vidx] += face_angles[j];
-                               vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) *
-                                                    face_angles[j];
+                               vert_accum[vidx] += angle;
+                               vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle;
                        }
                }
-       
-               BLI_array_free(face_angles);
  
                /* vertex group support */
                if (dvert) {
                                ml[j].v = ed->v1 + numVerts;
                                ml[j++].e = eidx + numEdges;
  
 -                              ml[j].v = ed->v2 + numVerts;
 -                              ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2];
 +                              ml[j].v = ed->v2+numVerts;
 +                              ml[j++].e = numEdges*2 + old_vert_arr[ed->v2];
                        }
                        
                        if (edge_origIndex) {
 -                              edge_origIndex[ml[j - 3].e] = ORIGINDEX_NONE;
 -                              edge_origIndex[ml[j - 1].e] = ORIGINDEX_NONE;
 +                              edge_origIndex[ml[j-3].e] = ORIGINDEX_NONE;
 +                              edge_origIndex[ml[j-1].e] = ORIGINDEX_NONE;
                        }
  
                        /* use the next material index if option enabled */
  
                        if (crease_inner) {
                                /* crease += crease_inner; without wrapping */
 -                              unsigned char *cr = (unsigned char *)&(medge[numEdges + eidx].crease);
 -                              int tcr = *cr + crease_inner;
 -                              *cr = tcr > 255 ? 255 : tcr;
 +                              unsigned char *cr= (unsigned char *)&(medge[numEdges + eidx].crease);
 +                              int tcr= *cr + crease_inner;
 +                              *cr= tcr > 255 ? 255 : tcr;
                        }
                        
  #ifdef SOLIDIFY_SIDE_NORMALS
index 01e5147d7883c357064eb421ba9cc7e62e0fc4b0,27c4a38c1315fee3ca16d5d6eade199028193732..ed57e305fc93cda0f486341744d2310a53b60fef
@@@ -84,6 -84,7 +84,6 @@@
  
  #include "ED_screen.h"
  #include "ED_util.h"
 -#include "ED_object.h"
  
  #include "RNA_access.h"
  #include "RNA_define.h"
@@@ -2134,7 -2135,12 +2134,7 @@@ static int wm_collada_export_invoke(bCo
  {     
        if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
                char filepath[FILE_MAX];
 -
 -              if (G.main->name[0] == 0)
 -                      BLI_strncpy(filepath, "untitled", sizeof(filepath));
 -              else
 -                      BLI_strncpy(filepath, G.main->name, sizeof(filepath));
 -
 +              BLI_strncpy(filepath, G.main->name, sizeof(filepath));
                BLI_replace_extension(filepath, sizeof(filepath), ".dae");
                RNA_string_set(op->ptr, "filepath", filepath);
        }
  static int wm_collada_export_exec(bContext *C, wmOperator *op)
  {
        char filename[FILE_MAX];
-       int selected, second_life;
+       int selected, second_life, apply_modifiers;
        
        if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
                BKE_report(op->reports, RPT_ERROR, "No filename given");
        }
  
        RNA_string_get(op->ptr, "filepath", filename);
-       selected = RNA_boolean_get(op->ptr, "selected");
-       second_life = RNA_boolean_get(op->ptr, "second_life");
-       if (collada_export(CTX_data_scene(C), filename, selected, second_life)) {
+       /* Options panel */
+       selected        = RNA_boolean_get(op->ptr, "selected");
+       second_life     = RNA_boolean_get(op->ptr, "second_life");
+       apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
+       /* get editmode results */
+       ED_object_exit_editmode(C, 0);  /* 0 = does not exit editmode */
+       if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) {
                return OPERATOR_FINISHED;
        }
        else {
@@@ -2177,8 -2190,10 +2184,10 @@@ static void WM_OT_collada_export(wmOper
        ot->poll = WM_operator_winactive;
        
        WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
-       RNA_def_boolean(ot->srna, "selected", 0, "Export only selected",
+       RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
                        "Export only selected elements");
+       RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
+                       "Apply modifiers (Preview Resolution)");
        RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life",
                        "Compatibility mode for Second Life");
  }