svn merge ^/trunk/blender -r42053:42069
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Nov 2011 15:33:44 +0000 (15:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Nov 2011 15:33:44 +0000 (15:33 +0000)
1  2 
release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/sculpt_paint/paint_image.c
source/blender/modifiers/intern/MOD_ocean.c

index 8e63da897a6be4e2e5418a6c24cba6e60b1a6016,e090b338a7dac0bef9c8743d59025c48a034c526..8e83eb5e7b84f2e2aa87fac9d90e164613390f3c
@@@ -262,6 -262,7 +262,7 @@@ class VIEW3D_MT_uv_map(Menu)
  
          layout.separator()
  
+         layout.operator_context = 'EXEC_REGION_WIN'
          layout.operator("uv.project_from_view")
          layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
  
@@@ -522,10 -523,11 +523,10 @@@ class VIEW3D_MT_select_edit_mesh(Menu)
  
          layout.separator()
  
 -        layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
 -        layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
 +        layout.operator("mesh.select_by_number_vertices", text = "By Number of Verts")
          if context.scene.tool_settings.mesh_select_mode[2] == False:
              layout.operator("mesh.select_non_manifold", text="Non Manifold")
 -        layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
 +        layout.operator("mesh.select_loose_verts", text = "Loose Verts/Edges")
          layout.operator("mesh.select_similar", text="Similar")
  
          layout.separator()
@@@ -1496,9 -1498,7 +1497,9 @@@ class VIEW3D_MT_edit_mesh_specials(Menu
          layout.operator_context = 'INVOKE_REGION_WIN'
  
          layout.operator("mesh.subdivide", text="Subdivide")
 +        """
          layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
 +        """
          layout.operator("mesh.merge", text="Merge...")
          layout.operator("mesh.remove_doubles")
          layout.operator("mesh.hide", text="Hide")
          layout.operator("mesh.select_inverse")
          layout.operator("mesh.flip_normals")
          layout.operator("mesh.vertices_smooth", text="Smooth")
 -        layout.operator("mesh.bevel", text="Bevel")
 +        layout.operator("mesh.bevel", text="Bevel")
          layout.operator("mesh.faces_shade_smooth")
          layout.operator("mesh.faces_shade_flat")
          layout.operator("mesh.blend_from_shape")
@@@ -1628,10 -1628,6 +1629,10 @@@ class VIEW3D_MT_edit_mesh_edges(Menu)
  
          layout.separator()
  
 +        layout.operator("mesh.bridge_edge_loops", text="Bridge Two Edge Loops")
 +
 +        layout.separator()
 +
          layout.operator("TRANSFORM_OT_edge_slide")
          layout.operator("TRANSFORM_OT_edge_crease")
          layout.operator("mesh.loop_multi_select", text="Edge Loop")
index 7625633ea6c049d34768e9b79a55869b9b2bb09c,e1a45a6367cf93db59ed6a9f789ace1ae6ebefce..3bca2f46efe1bca38b68da9f5bea138544660d07
@@@ -300,6 -300,7 +300,7 @@@ typedef struct ProjPaintState 
        short do_occlude;                       /* Use raytraced occlusion? - ortherwise will paint right through to the back*/
        short do_backfacecull;  /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
        short do_mask_normal;                   /* mask out pixels based on their normals */
+       short do_new_shading_nodes;     /* cache scene_use_new_shading_nodes value */
        float normal_angle;                             /* what angle to mask at*/
        float normal_angle_inner;
        float normal_angle_range;               /* difference between normal_angle and normal_angle_inner, for easy access */
@@@ -518,17 -519,16 +519,16 @@@ static Image *imapaint_face_image(cons
        return ima;
  }
  
- static Image *project_paint_face_image(const ProjPaintState *ps, int face_index)
+ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtface, int face_index)
  {
        Image *ima;
  
-       if(scene_use_new_shading_nodes(ps->scene)) {
+       if(ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */
                MFace *mf = ps->dm_mface+face_index;
                ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL);
        }
        else {
-               MTFace *tf = ps->dm_mtface+face_index;
-               ima = tf->tpage;
+               ima = dm_mtface[face_index].tpage;
        }
  
        return ima;
@@@ -725,7 -725,7 +725,7 @@@ static int project_paint_PickColor(cons
                interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
        }
  
-       ima = project_paint_face_image(ps, face_index);
+       ima = project_paint_face_image(ps, ps->dm_mtface, face_index);
        ibuf = ima->ibufs.first; /* we must have got the imbuf before getting here */
        if (!ibuf) return 0;
        
@@@ -1091,8 -1091,8 +1091,8 @@@ static int check_seam(const ProjPaintSt
                        
                        /* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
                        if (i2_fidx != -1) {
-                               Image *tpage = project_paint_face_image(ps, face_index);
-                               Image *orig_tpage = project_paint_face_image(ps, orig_face);
+                               Image *tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
+                               Image *orig_tpage = project_paint_face_image(ps, ps->dm_mtface, orig_face);
  
                                /* This IS an adjacent face!, now lets check if the UVs are ok */
                                tf = ps->dm_mtface + face_index;
@@@ -1349,7 -1349,7 +1349,7 @@@ static float project_paint_uvpixel_mask
        if (ps->do_layer_stencil) {
                /* another UV layers image is masking this one's */
                ImBuf *ibuf_other;
-               Image *other_tpage = project_paint_face_image(ps, face_index);
+               Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_stencil, face_index);
                const MTFace *tf_other = ps->dm_mtface_stencil + face_index;
                
                if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
@@@ -1506,7 -1506,7 +1506,7 @@@ static ProjPixel *project_paint_uvpixel
        if (ps->tool==PAINT_TOOL_CLONE) {
                if (ps->dm_mtface_clone) {
                        ImBuf *ibuf_other;
-                       Image *other_tpage = project_paint_face_image(ps, face_index);
+                       Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_clone, face_index);
                        const MTFace *tf_other = ps->dm_mtface_clone + face_index;
                        
                        if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
@@@ -2746,7 -2746,7 +2746,7 @@@ static void project_bucket_init(const P
                        face_index = GET_INT_FROM_POINTER(node->link);
                                
                        /* Image context switching */
-                       tpage = project_paint_face_image(ps, face_index);
+                       tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
                        if (tpage_last != tpage) {
                                tpage_last = tpage;
  
@@@ -2962,11 -2962,11 +2962,11 @@@ static void project_paint_begin(ProjPai
        }
        
        ps->dm_mvert = ps->dm->getVertArray(ps->dm);
 -      ps->dm_mface = ps->dm->getFaceArray(ps->dm);
 -      ps->dm_mtface= ps->dm->getFaceDataArray(ps->dm, CD_MTFACE);
 +      ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
 +      ps->dm_mtface= ps->dm->getTessFaceDataArray(ps->dm, CD_MTFACE);
        
        ps->dm_totvert = ps->dm->getNumVerts(ps->dm);
 -      ps->dm_totface = ps->dm->getNumFaces(ps->dm);
 +      ps->dm_totface = ps->dm->getNumTessFaces(ps->dm);
        
        /* use clone mtface? */
        
        }
        
        /* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */
 -      if(ps->dm->type != DM_TYPE_CDDM) {
 +      // this seems like a bad check, since some constructive modifiers use cddm? - joeedh
 +      if(1) { //ps->dm->type != DM_TYPE_CDDM) {
                ps->dm_mvert= MEM_dupallocN(ps->dm_mvert);
                ps->dm_mface= MEM_dupallocN(ps->dm_mface);
                /* looks like these are ok for now.*/
 -              /*
 +              
                ps->dm_mtface= MEM_dupallocN(ps->dm_mtface);
 -              ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone);
 -              ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil);
 -               */
 +              if (ps->dm_mtface_clone)
 +                      ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone);
 +              if (ps->dm_mtface_stencil)
 +                      ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil);
 +               
        }
        
        ps->viewDir[0] = 0.0f;
                }
  #endif
                
-               tpage = project_paint_face_image(ps, face_index);
+               tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
  
                if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) {
                        
@@@ -3489,8 -3486,7 +3489,8 @@@ static void project_paint_end(ProjPaint
        }
        
        /* copy for subsurf/multires, so throw away */
 -      if(ps->dm->type != DM_TYPE_CDDM) {
 +      // this seems like a bad check, since some constructive modifiers use cddm? - joeedh
 +      if(1) { //ps->dm->type != DM_TYPE_CDDM) {
                if(ps->dm_mvert) MEM_freeN(ps->dm_mvert);
                if(ps->dm_mface) MEM_freeN(ps->dm_mface);
                /* looks like these dont need copying */
@@@ -4718,6 -4714,7 +4718,7 @@@ static void project_state_init(bContex
        ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1;
        ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1;
        ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1;
+       ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */
  
        if (ps->tool == PAINT_TOOL_CLONE)
                ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE);
@@@ -4799,20 -4796,9 +4800,20 @@@ static int texture_paint_init(bContext 
        pop->orig_brush_size= brush_size(brush);
  
        if(pop->mode != PAINT_MODE_2D) {
 +              Mesh *me;
 +
                pop->s.ob = OBACT;
 +              if (!pop->ps.ob)
 +                      pop->ps.ob = pop->s.ob;
 +              
                pop->s.me = get_mesh(pop->s.ob);
                if (!pop->s.me) return 0;
 +              
 +              me = pop->s.me;
 +
 +              /* Dont allow brush size below 2 */
 +              if (pop->ps.brush && pop->ps.brush->size<=1)
 +                      pop->ps.brush->size = 2;
        }
        else {
                pop->s.image = pop->s.sima->image;
index 9377fdc115dfea1d93832fcce2e23925f1dbde18,434b9e00f0eea10c20a52b5a242e4d026756fdd8..991b4afe073526289e64211126660182667f11b5
@@@ -404,7 -404,8 +404,8 @@@ static DerivedMesh *doOcean(ModifierDat
        if (omd->cached == TRUE) {
                if (!omd->oceancache) init_cache_data(ob, omd);
                BKE_simulate_ocean_cache(omd->oceancache, md->scene->r.cfra);
-       } else {
+       }
+       else {
                simulate_ocean_modifier(omd);
        }
  
                mf = dm->getFaceArray(dm);
  
                for (i = 0; i < num_faces; i++, mf++) {
-                       for (j=0; j<4; j++) {
-                               if (j == 3 && !mf->v4) continue;
-                               switch(j) {
-                                       case 0:
-                                               u = ocean_co(omd, mv[mf->v1].co[0]);
-                                               v = ocean_co(omd, mv[mf->v1].co[1]);
-                                               break;
-                                       case 1:
-                                               u = ocean_co(omd, mv[mf->v2].co[0]);
-                                               v = ocean_co(omd, mv[mf->v2].co[1]);
-                                               break;
-                                       case 2:
-                                               u = ocean_co(omd, mv[mf->v3].co[0]);
-                                               v = ocean_co(omd, mv[mf->v3].co[1]);
-                                               break;
-                                       case 3:
-                                               u = ocean_co(omd, mv[mf->v4].co[0]);
-                                               v = ocean_co(omd, mv[mf->v4].co[1]);
-                                               break;
-                               }
+                       j= mf->v4 ? 3 : 2;
+                       do {
+                               const float *co= mv[*(&mf->v1 + j)].co;
+                               u = ocean_co(omd, co[0]);
+                               v = ocean_co(omd, co[1]);
  
                                if (omd->oceancache && omd->cached==TRUE) {
                                        BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
                                        foam = ocr.foam;
                                        CLAMP(foam, 0.0f, 1.0f);
-                               } else {
+                               }
+                               else {
                                        BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
                                        foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage);
                                }
  
-                               cf = (char)(foam*255);
+                               cf = (char)(foam * 255);
                                mc[i*4 + j].r = mc[i*4 + j].g = mc[i*4 + j].b = cf;
                                mc[i*4 + j].a = 255;
-                       }
+                       } while (j--);
                }
        }
  
@@@ -534,7 -518,7 +518,7 @@@ static DerivedMesh *applyModifier(Modif
  }
  
  static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
 -                                                                      struct EditMesh *UNUSED(editData),
 +                                                                      struct BMEditMesh *UNUSED(editData),
                                                                        DerivedMesh *derivedData)
  {
        return applyModifier(md, ob, derivedData, 0, 1);