svn merge ^/trunk/blender -r42973:42991
authorCampbell Barton <ideasman42@gmail.com>
Fri, 30 Dec 2011 09:23:06 +0000 (09:23 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 30 Dec 2011 09:23:06 +0000 (09:23 +0000)
12 files changed:
1  2 
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/collada/MeshImporter.cpp
source/blender/editors/object/object_bake.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/makesdna/DNA_defs.h
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_vec_types.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 1f475ea62e62fedcb3f9eb08b0f5a1c0b5cb0bbb,ce50c58a6e100229423340ab145ef6552a7d2c86..921e62769bf7079097af4d2332c4e3a2272799df
@@@ -4515,7 -4524,9 +4525,8 @@@ void psys_make_billboard(ParticleBillbo
        madd_v3_v3fl(center, yvec, bb->offset[1]);
  }
  
- void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) {
 -
+ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
+ {
        ParticleSimulationData sim= {0};
        sim.scene= scene;
        sim.ob= ob;
index 16198e9e50e9a7260a8cc5830dd3fea63a5b7a74,a02b90a1d1675e4a58a7c4df3dfaa1ea8020aa13..c3c3f91e37df9716fd4832ba4d1abf987b5bb35d
@@@ -997,12 -997,7 +997,9 @@@ static DerivedMesh *multiresbake_create
        *lvl= mmd->lvl;
  
        if(*lvl==0) {
-               /* BMESH_TODO, baking from level zero currently doesnt give correct results */
 -              return NULL;
 +              DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob);
 +              dm= CDDM_copy(tmp_dm, 0);
 +              tmp_dm->release(tmp_dm);
        } else {
                MultiresModifierData tmp_mmd= *mmd;
                DerivedMesh *cddm= CDDM_from_mesh(me, ob);
index 23e937e3d71c70f23363392ff513575a9f20a5c3,3cb613ac5ca2271a3f40a0bd938e10d42dceb14a..860afdb2b50dfd1bf784dbe7dfb9d85efb821434
@@@ -104,7 -102,7 +104,7 @@@ int vertex_paint_mode_poll(bContext *C
  {
        Object *ob = CTX_data_active_object(C);
  
--      return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totface;
++      return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly;
  }
  
  int vertex_paint_poll(bContext *C)
@@@ -125,7 -123,7 +125,7 @@@ int weight_paint_mode_poll(bContext *C
  {
        Object *ob = CTX_data_active_object(C);
  
--      return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totface;
++      return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly;
  }
  
  int weight_paint_poll(bContext *C)
@@@ -161,7 -159,7 +161,7 @@@ static VPaint *new_vpaint(int wpaint
  
  static int *get_indexarray(Mesh *me)
  {
--      return MEM_mallocN(sizeof(int)*(me->totface+1), "vertexpaint");
++      return MEM_mallocN(sizeof(int)*(me->totpoly+1), "vertexpaint");
  }
  
  
@@@ -423,14 -357,12 +423,14 @@@ static void copy_wpaint_prev (VPaint *w
  void vpaint_fill(Object *ob, unsigned int paintcol)
  {
        Mesh *me;
 -      MFace *mf;
 +      MFace *mf;
 +      MPoly *mp;
 +      MLoopCol *lcol;
        unsigned int *mcol;
 -      int i, selected;
 +      int i, j, selected;
  
        me= get_mesh(ob);
--      if(me==NULL || me->totface==0) return;
++      if(me==NULL || me->totpoly==0) return;
  
        if(!me->mcol) make_vertexcol(ob);
        if(!me->mcol) return; /* possible we can't make mcol's */
  void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
  {
        Mesh *me= ob->data;
 -      MFace *mf;
 +      MPoly *mf;
        MDeformWeight *dw, *uw;
-       int vgroup, vgroup_mirror= -1;
+       int vgroup_active, vgroup_mirror= -1;
        unsigned int index;
  
        /* mutually exclusive, could be made into a */
        const short paint_selmode= ME_EDIT_PAINT_SEL_MODE(me);
  
 -      if(me->totface==0 || me->dvert==NULL || !me->mface) return;
 +      if(me->totpoly==0 || me->dvert==NULL || !me->mpoly) return;
        
-       vgroup= ob->actdef-1;
+       vgroup_active = ob->actdef - 1;
  
        /* if mirror painting, find the other group */
        if(me->editflag & ME_EDIT_MIRROR_X) {
  }
  
  /* XXX: should be re-implemented as a vertex/weight paint 'color correct' operator
-- 
++
  void vpaint_dogamma(Scene *scene)
  {
        VPaint *vp= scene->toolsettings->vpaint;
  
        igam= 1.0/vp->gamma;
        for(a=0; a<256; a++) {
--              
++
                fac= ((float)a)/255.0;
                fac= vp->mul*pow( fac, igam);
--              
++
                temp= 255.9*fac;
--              
++
                if(temp<=0) gamtab[a]= 0;
                else if(temp>=255) gamtab[a]= 255;
                else gamtab[a]= temp;
        a= 4*me->totface;
        cp= (unsigned char *)me->mcol;
        while(a--) {
--              
++
                cp[1]= gamtab[ cp[1] ];
                cp[2]= gamtab[ cp[2] ];
                cp[3]= gamtab[ cp[3] ];
--              
++
                cp+= 4;
        }
  }
   */
  
++
  static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
  {
        char *cp1, *cp2, *cp;
@@@ -969,8 -897,8 +978,8 @@@ static int weight_sample_invoke(bContex
                                BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations");
                        }
                        else {
 -                              MFace *mf= ((MFace *)me->mface) + index-1;
 +                              MPoly *mf= ((MPoly *)me->mpoly) + index-1;
-                               const int vgroup= vc.obact->actdef - 1;
+                               const int vgroup_active= vc.obact->actdef - 1;
                                ToolSettings *ts= vc.scene->toolsettings;
                                float mval_f[2];
                                int v_idx_best= -1;
@@@ -1046,11 -974,11 +1055,11 @@@ static EnumPropertyItem *weight_paint_s
  
                                index= view3d_sample_backbuf(&vc, win->eventstate->x - vc.ar->winrct.xmin, win->eventstate->y - vc.ar->winrct.ymin);
  
--                              if(index && index<=me->totface) {
++                              if(index && index<=me->totpoly) {
                                        const int defbase_tot= BLI_countlist(&vc.obact->defbase);
                                        if(defbase_tot) {
 -                                              MFace *mf= ((MFace *)me->mface) + index-1;
 -                                              unsigned int fidx= mf->v4 ? 3:2;
 +                                              MPoly *mf= ((MPoly *)me->mpoly) + index-1;
 +                                              unsigned int fidx= mf->totloop - 1;
                                                int *groups= MEM_callocN(defbase_tot*sizeof(int), "groups");
                                                int found= FALSE;
  
@@@ -1956,7 -1888,7 +1969,7 @@@ static int wpaint_stroke_test_start(bCo
        if(scene->obedit) return OPERATOR_CANCELLED;
        
        me= get_mesh(ob);
--      if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH;
++      if(me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH;
        
        /* if nothing was added yet, we make dverts and a vertex deform group */
        if (!me->dvert) {
@@@ -2096,7 -2053,7 +2134,7 @@@ static void wpaint_stroke_update_step(b
        if(wp->flag & VP_AREA) {
                /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */
                me->editflag &= ~ME_EDIT_VERT_SEL;
-               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush_size(brush));
 -              totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush_size_final);
++              totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_final);
                me->editflag |= use_vert_sel ? ME_EDIT_VERT_SEL : 0;
        }
        else {
                                        dw_func= (MDeformWeight *(*)(MDeformVert *, const int))defvert_find_index;
                                else
                                        dw_func= defvert_verify_index;
 -
 -                              do {
 -                                      unsigned int vidx= *(&mface->v1 + fidx);
 -                                      const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos+6*vidx, mval, brush_size_final);
 +                                              
 +                              ml = me->mloop + mpoly->loopstart;
 +                              for (i=0; i<mpoly->totloop; i++, ml++) {
-                                       dw = dw_func(me->dvert+ml->v, ob->actdef-1);
-                                       if (dw) {
-                                               paintweight += dw->weight;
-                                               totw++;
++                                      const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos+6*ml->v, mval, brush_size_final);
+                                       if (fac > 0.0f) {
 -                                              dw = dw_func(&me->dvert[vidx], wpi.vgroup_active);
++                                              dw = dw_func(&me->dvert[ml->v], wpi.vgroup_active);
+                                               paintweight += dw ? (dw->weight * fac) : 0.0f;
+                                               totw += fac;
                                        }
 -
 -                              } while (fidx--);
 -
 +                              }
                        }
                }
        }
                        
-       if(brush->vertexpaint_tool==VP_BLUR) 
-               paintweight/= (float)totw;
-                       
+       if (brush->vertexpaint_tool==VP_BLUR) {
+               paintweight /= totw;
+       }
        for(index=0; index<totindex; index++) {
 -                              
 -              if(indexar[index] && indexar[index]<=me->totface) {
 -                      MFace *mf= me->mface + (indexar[index]-1);
 -                      unsigned int fidx= mf->v4 ? 3:2;
 -                      do {
 -                              unsigned int vidx= *(&mf->v1 + fidx);
 -
 -                              if(me->dvert[vidx].flag) {
 +              if(indexar[index] && indexar[index]<=me->totpoly) {
 +                      MPoly *mpoly= me->mpoly + (indexar[index]-1);
 +                      MLoop *ml=me->mloop+mpoly->loopstart;
 +                      int i;
 +
 +                      for (i=0; i<mpoly->totloop; i++, ml++) {
 +                              unsigned int vidx= ml->v;
 +                              if (me->dvert[vidx].flag) {
-                                       alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx, mval, pressure);
+                                       alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx,
+                                                               mval, brush_size_final, brush_alpha_final);
                                        if(alpha) {
                                                do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight);
                                        }
@@@ -2487,8 -2408,10 +2528,11 @@@ static int vpaint_stroke_test_start(bCo
        return 1;
  }
  
- static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, const float mval[2], float pressure, int UNUSED(flip))
 +#if 0
+ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
+                               const unsigned int index, const float mval[2],
+                               const float brush_size_final, const float brush_alpha_final,
+                               int UNUSED(flip))
  {
        ViewContext *vc = &vpd->vc;
        Brush *brush = paint_brush(&vp->paint);
        }
  
        for(i = 0; i < (mface->v4 ? 4 : 3); ++i) {
-               alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i], mval, pressure);
-               if(alpha)
+               alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i],
+                                        mval, brush_size_final, brush_alpha_final);
+               if(alpha) {
                        vpaint_blend(vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
+               }
        }
  }
 +#endif
  
  static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
  {
  
        RNA_float_get_array(itemptr, "mouse", mval);
        flip = RNA_boolean_get(itemptr, "pen_flip");
-       pressure = RNA_float_get(itemptr, "pressure");
 -                      
 +
 +      (void)flip; /* BMESH_TODO */
 +
        view3d_operator_needs_opengl(C);
                        
        /* load projection matrix */
                        
        /* which faces are involved */
        if(vp->flag & VP_AREA) {
-               totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size(brush));
 -              totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush_size_final);
++              totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_final);
        }
        else {
                indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
                        
        swap_m4m4(vc->rv3d->persmat, mat);
                        
 -      for(index=0; index<totindex; index++) {                         
 -              if (indexar[index] && indexar[index]<=me->totface) {
 -                      vpaint_paint_face(vp, vpd, ob, indexar[index]-1, mval, brush_size_final, brush_alpha_final, flip);
 +      if(vp->flag & VP_COLINDEX) {
 +              for(index=0; index<totindex; index++) {
 +                      if(indexar[index] && indexar[index]<=me->totpoly) {
 +                              MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
 +                                              
 +                              if(mpoly->mat_nr!=ob->actcol-1) {
 +                                      indexar[index]= 0;
 +                              }
-                       }                                       
++                      }
                }
        }
 +
 +      if((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) {
 +              for(index=0; index<totindex; index++) {
 +                      if(indexar[index] && indexar[index]<=me->totpoly) {
 +                              MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
                                                
 +                              if((mpoly->flag & ME_FACE_SEL)==0)
 +                                      indexar[index]= 0;
 +                      }                                       
 +              }
 +      }
 +      
        swap_m4m4(vc->rv3d->persmat, mat);
  
        /* was disabled because it is slow, but necessary for blur */
        if(brush->vertexpaint_tool == VP_BLUR)
                do_shared_vertexcol(me);
                        
 -      ED_region_tag_redraw(vc->ar);
 +      for(index=0; index<totindex; index++) {
 +                              
 +              if(indexar[index] && indexar[index]<=me->totpoly) {
 +                      MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
 +                      MFace *mf;
 +                      MCol *mc;
 +                      MLoop *ml;
 +                      MLoopCol *mlc;
 +                      unsigned int *lcol = ((unsigned int*)me->mloopcol) + mpoly->loopstart;
 +                      unsigned int *lcolorig = ((unsigned int*)vp->vpaint_prev) + mpoly->loopstart;
 +                      float alpha;
 +                      int i, j;
 +                                      
 +                      if(brush->vertexpaint_tool==VP_BLUR) {
 +                              unsigned int blend[5] = {0};
 +                              char *col;
 +
 +                              for (j=0; j<mpoly->totloop; j += 2) {
 +                                      col = (char*)(lcol + j);
 +                                      blend[0] += col[0];
 +                                      blend[1] += col[1];
 +                                      blend[2] += col[2];
 +                                      blend[3] += col[3];
 +                              }
 +
 +                              blend[0] /= mpoly->totloop;
 +                              blend[1] /= mpoly->totloop;
 +                              blend[2] /= mpoly->totloop;
 +                              blend[3] /= mpoly->totloop;
 +                              col = (char*)(blend + 4);
 +                              col[0] = blend[0];
 +                              col[1] = blend[1];
 +                              col[2] = blend[2];
 +                              col[3] = blend[3];
 +
 +                              vpd->paintcol = *((unsigned int*)col);
 +                      }
 +
 +                      ml = me->mloop + mpoly->loopstart;
 +                      for (i=0; i<mpoly->totloop; i++, ml++) {
 +                              alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, 
-                                          vpd->vertexcosnos+6*ml->v, mval, pressure);
++                                                      vpd->vertexcosnos+6*ml->v, mval,
++                                                      brush_size_final, brush_alpha_final);
 +                              if(alpha > 0.0f) vpaint_blend(vp, lcol+i, lcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
 +                      }
 +      
 +                      #ifdef CPYCOL
 +                      #undef CPYCOL
 +                      #endif
 +                      #define CPYCOL(c, l) (c)->a = (l)->a, (c)->r = (l)->r, (c)->g = (l)->g, (c)->b = (l)->b
 +
 +                      /*update vertex colors for tesselations incrementally,
 +                        rather then regenerating the tesselation altogether.*/
 +                      for (e=vpd->polyfacemap[(indexar[index]-1)].first; e; e=e->next) {
 +                              mf = me->mface + e->facenr;
 +                              mc = me->mcol + e->facenr*4;
 +                              
 +                              ml = me->mloop + mpoly->loopstart;
 +                              mlc = me->mloopcol + mpoly->loopstart;
 +                              for (j=0; j<mpoly->totloop; j++, ml++, mlc++) {
 +                                      if (ml->v == mf->v1)
 +                                              CPYCOL(mc, mlc);
 +                                      else if (ml->v == mf->v2)
 +                                              CPYCOL(mc+1, mlc);
 +                                      else if (ml->v == mf->v3)
 +                                              CPYCOL(mc+2, mlc);
 +                                      else if (mf->v4 && ml->v == mf->v4)
 +                                              CPYCOL(mc+3, mlc);
 +
 +                              }
 +                      }
 +                      #undef CPYCOL
 +              }
 +      }
 +              
 +      swap_m4m4(vc->rv3d->persmat, mat);
                        
 +      /* was disabled because it is slow, but necessary for blur */
 +      if(brush->vertexpaint_tool == VP_BLUR) {
 +              do_shared_vertexcol(me);
 +      }
 +
 +      ED_region_tag_redraw(vc->ar);           
        DAG_id_tag_update(ob->data, 0);
  }
  
Simple merge