Commit: fc99c5759217ac2853ec521ca1896c0009ccda1a
Author: Campbell Barton
Date:   Tue Jul 14 23:00:55 2015 +1000
Branches: temp-derivedmesh-looptri
https://developer.blender.org/rBfc99c5759217ac2853ec521ca1896c0009ccda1a

Merge branch 'master' into temp-derivedmesh-looptri

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/cdderivedmesh.c
index 4b1bd2b,b03024c..f67a019
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@@ -479,9 -470,9 +479,9 @@@ static void cdDM_drawFacesTex_common(De
                                       void *userData, DMDrawFlag uvflag)
  {
        CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
-       MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
 -      const MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
+       MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
 -      MCol *mcol;
 +      const MPoly *mpoly = cddm->mpoly;
 +      MLoopCol *mloopcol;
        int i, orig;
        int colType, startFace = 0;
        bool use_tface = (uvflag & DM_DRAW_USE_ACTIVE_UV) != 0;
@@@ -540,14 -537,16 +540,14 @@@
                int flush = 0;
                
                if (i != tottri - 1)
 -                      next_actualFace = dm->drawObject->triangle_to_mface[i + 
1];
 +                      next_actualFace = dm->drawObject->triangle_to_mpoly[i + 
1];
                
 -              orig = index_mf_to_mpoly ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace) : 
ORIGINDEX_NONE;
 -
                if (drawParams) {
-                       draw_option = drawParams(use_tface && tf ? 
&tf[actualFace] : NULL, (mloopcol != NULL), mpoly[actualFace].mat_nr);
 -                      MTexPoly *tp = (use_tface && mtexpoly && orig != 
ORIGINDEX_NONE) ? &mtexpoly[orig] : NULL;
 -                      draw_option = drawParams(tp, (mcol != NULL), 
mf[actualFace].mat_nr);
++                      draw_option = drawParams(use_tface && mtexpoly ? 
&mtexpoly[actualFace] : NULL, (mloopcol != NULL), mpoly[actualFace].mat_nr);
                }
                else {
 -                      if (index_mf_to_mpoly) {
 +                      if (index_mp_to_orig) {
 +                              orig = index_mp_to_orig[actualFace];
                                if (orig == ORIGINDEX_NONE) {
                                        /* XXX, this is not really correct
                                                         * it will draw the 
previous faces context for this one when we don't know its settings.
diff --cc source/blender/editors/space_view3d/drawmesh.c
index 1ef3894,35e2ca8..11b4079
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@@ -79,9 -79,9 +79,9 @@@ typedef struct drawMeshFaceSelect_userD
  typedef struct drawEMTFMapped_userData {
        BMEditMesh *em;
        bool has_mcol;
-       bool has_mtface;
+       int cd_poly_tex_offset;
 -      MFace *mf;
 -      MTFace *tf;
 +      const MPoly *mp;
 +      const MTexPoly *tf;
  } drawEMTFMapped_userData;
  
  typedef struct drawTFace_userData {
@@@ -590,65 -590,60 +590,65 @@@ static DMDrawOption draw_tface__set_dra
  
  static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
  {
-       MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE);
+       MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
 -      MFace *mface = dm->getTessFaceArray(dm);
 -      MCol *finalCol;
 +      const MPoly *mpoly = dm->getPolyArray(dm);
 +      const MLoopTri *lt = dm->looptris.array;
 +      MLoopCol *finalCol;
        int i, j;
 -      MCol *mcol = NULL;
 +      MLoopCol *mloopcol = NULL;
  
        if (use_mcol) {
 -              mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
 -              if (!mcol)
 -                      mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
 +              mloopcol = dm->getLoopDataArray(dm, CD_PREVIEW_MLOOPCOL);
 +              if (!mloopcol)
 +                      mloopcol = dm->getLoopDataArray(dm, CD_MLOOPCOL);
        }
  
 -      if (CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) {
 -              finalCol = CustomData_get_layer(&dm->faceData, CD_TEXTURE_MCOL);
 +      if (CustomData_has_layer(&dm->loopData, CD_TEXTURE_MLOOPCOL)) {
 +              finalCol = CustomData_get_layer(&dm->loopData, 
CD_TEXTURE_MLOOPCOL);
        }
        else {
 -              finalCol = MEM_mallocN(sizeof(MCol) * 4 * 
dm->getNumTessFaces(dm), "add_tface_color_layer");
 -
 -              CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, 
finalCol, dm->numTessFaceData);
 +              finalCol = MEM_mallocN(sizeof(MLoopCol) * dm->numLoopData, 
"add_tface_color_layer");
 +              CustomData_add_layer(&dm->loopData, CD_TEXTURE_MLOOPCOL, 
CD_ASSIGN, finalCol, dm->numLoopData);
        }
  
 -      for (i = 0; i < dm->getNumTessFaces(dm); i++) {
 -              Material *ma = give_current_material(Gtexdraw.ob, 
mface[i].mat_nr + 1);
 +      for (i = 0; i < dm->looptris.num; i++) {
 +              const MPoly *mp = &mpoly[lt->poly];
 +              const unsigned int *ltri = lt->tri;
 +              Material *ma = give_current_material(Gtexdraw.ob, mp->mat_nr + 
1);
  
                if (ma && (ma->game.flag & GEMAT_INVISIBLE)) {
 -                      if (mcol)
 -                              memcpy(&finalCol[i * 4], &mcol[i * 4], 
sizeof(MCol) * 4);
 +                      if (mloopcol) {
 +                              for (j = 0; j < 3; j++) {
 +                                      finalCol[ltri[j]] = mloopcol[ltri[j]];
 +                              }
 +                      }
                        else
 -                              for (j = 0; j < 4; j++) {
 -                                      finalCol[i * 4 + j].b = 255;
 -                                      finalCol[i * 4 + j].g = 255;
 -                                      finalCol[i * 4 + j].r = 255;
 +                              for (j = 0; j < 3; j++) {
 +                                      finalCol[ltri[j]].b = 255;
 +                                      finalCol[ltri[j]].g = 255;
 +                                      finalCol[ltri[j]].r = 255;
                                }
                }
-               else if (tface && set_draw_settings_cached(0, tface, ma, 
Gtexdraw)) {
+               else if (mtexpoly && set_draw_settings_cached(0, mtexpoly, ma, 
Gtexdraw)) {
 -                      for (j = 0; j < 4; j++) {
 -                              finalCol[i * 4 + j].b = 255;
 -                              finalCol[i * 4 + j].g = 0;
 -                              finalCol[i * 4 + j].r = 255;
 +                      for (j = 0; j < 3; j++) {
 +                              finalCol[ltri[j]].b = 255;
 +                              finalCol[ltri[j]].g = 0;
 +                              finalCol[ltri[j]].r = 255;
                        }
                }
                else if (ma && (ma->shade_flag & MA_OBCOLOR)) {
 -                      for (j = 0; j < 4; j++) {
 -                              finalCol[i * 4 + j].b = Gtexdraw.obcol[0];
 -                              finalCol[i * 4 + j].g = Gtexdraw.obcol[1];
 -                              finalCol[i * 4 + j].r = Gtexdraw.obcol[2];
 +                      for (j = 0; j < 3; j++) {
 +                              finalCol[ltri[j]].b = Gtexdraw.obcol[0];
 +                              finalCol[ltri[j]].g = Gtexdraw.obcol[1];
 +                              finalCol[ltri[j]].r = Gtexdraw.obcol[2];
                        }
                }
 -              else if (!mcol) {
 +              else if (!mloopcol) {
-                       if (tface) {
+                       if (mtexpoly) {
 -                              for (j = 0; j < 4; j++) {
 -                                      finalCol[i * 4 + j].b = 255;
 -                                      finalCol[i * 4 + j].g = 255;
 -                                      finalCol[i * 4 + j].r = 255;
 +                              for (j = 0; j < 3; j++) {
 +                                      finalCol[ltri[j]].b = 255;
 +                                      finalCol[ltri[j]].g = 255;
 +                                      finalCol[ltri[j]].r = 255;
                                }
                        }
                        else {
@@@ -922,9 -924,10 +927,10 @@@ static void draw_mesh_textured_old(Scen
  
                data.em = me->edit_btmesh;
                data.has_mcol = 
CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL);
-               data.has_mtface = 
CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
+               data.cd_poly_tex_offset = 
CustomData_get_offset(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
+ 
 -              data.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
 -              data.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
 +              data.mp = DM_get_poly_data_layer(dm, CD_MPOLY);
 +              data.tf = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
  
                dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, 
compareDrawOptionsEm, &data, 0);
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to