svn merge ^/trunk/blender -r43819:43830
authorCampbell Barton <ideasman42@gmail.com>
Thu, 2 Feb 2012 00:04:47 +0000 (00:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 2 Feb 2012 00:04:47 +0000 (00:04 +0000)
1  2 
source/blender/editors/mesh/mesh_data.c
source/blender/editors/object/object_bake.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/intern/MOD_fluidsim_util.c

@@@ -302,63 -175,40 +302,63 @@@ int ED_mesh_uv_loop_reset(struct bConte
  
  int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
  {
 -      EditMesh *em;
 +      BMEditMesh *em;
        int layernum;
  
 -      if(me->edit_mesh) {
 -              em= me->edit_mesh;
 +      if (me->edit_btmesh) {
 +              em= me->edit_btmesh;
  
 -              layernum= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
 -              if(layernum >= MAX_MTFACE)
 +              layernum = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
 +              if (layernum >= MAX_MTFACE)
-                       return 0;
+                       return -1;
  
 -              EM_add_data_layer(em, &em->fdata, CD_MTFACE, name);
 +              BM_add_data_layer(em->bm, &em->bm->pdata, CD_MTEXPOLY);
 +              CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum);
 +              CustomData_set_layer_name(&em->bm->pdata, CD_MTEXPOLY, layernum, name);
  
 -              if(layernum) /* copy data from active UV */
 +              /* copy data from active UV */
 +              if (layernum)
                        copy_editface_active_customdata(em, CD_MTFACE, layernum);
  
 -              if(active_set || layernum==0)
 -                      CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum);
 +              if (active_set || layernum == 0) {
 +                      CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum);
 +              }
 +
 +              BM_add_data_layer(em->bm, &em->bm->ldata, CD_MLOOPUV);
 +              CustomData_set_layer_name(&em->bm->ldata, CD_MLOOPUV, layernum, name);
 +              
 +              CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
 +              if(active_set || layernum == 0) {
 +                      CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
 +              }
        }
        else {
 -              layernum= CustomData_number_of_layers(&me->fdata, CD_MTFACE);
 -              if(layernum >= MAX_MTFACE)
 +              layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
 +              if (layernum >= MAX_MTFACE)
-                       return 0;
+                       return -1;
  
 -              if(me->mtface)
 +              if (me->mtpoly) {
 +                      CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name);
 +                      CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name);
                        CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name);
 -              else
 +              } else {
 +                      CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name);
 +                      CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name);
                        CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
 +              }
 +              
 +              if (active_set || layernum == 0) {
 +                      CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum);
 +                      CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum);
  
 -              if(active_set || layernum==0)
                        CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum);
 +              }
  
 -              mesh_update_customdata_pointers(me);
 +              mesh_update_customdata_pointers(me, TRUE);
        }
  
 +      ED_mesh_uv_loop_reset(C, me);
 +
        DAG_id_tag_update(&me->id, 0);
        WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
  
@@@ -391,50 -236,38 +391,50 @@@ int ED_mesh_uv_texture_remove(bContext 
  
  int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set)
  {
 -      EditMesh *em;
 +      BMEditMesh *em;
        int layernum;
  
 -      if(me->edit_mesh) {
 -              em= me->edit_mesh;
 +      if (me->edit_btmesh) {
 +              em= me->edit_btmesh;
  
 -              layernum= CustomData_number_of_layers(&em->fdata, CD_MCOL);
 -              if(layernum >= MAX_MCOL)
 +              layernum= CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
 +              if (layernum >= MAX_MCOL) {
-                       return 0;
+                       return -1;
 +              }
  
 -              EM_add_data_layer(em, &em->fdata, CD_MCOL, name);
 +              BM_add_data_layer(em->bm, &em->bm->pdata, CD_MLOOPCOL);
 +              CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
  
 -              if(layernum) /* copy data from active vertex color layer */
 +              /* copy data from active vertex color layer */
 +              if (layernum) {
                        copy_editface_active_customdata(em, CD_MCOL, layernum);
 +              }
  
 -              if(active_set || layernum==0)
 -                      CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum);
 +              if (active_set || layernum == 0) {
 +                      CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
 +              }
        }
        else {
 -              layernum= CustomData_number_of_layers(&me->fdata, CD_MCOL);
 -              if(layernum >= MAX_MCOL)
 +              layernum= CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
 +              if (layernum >= CD_MLOOPCOL) {
-                       return 0;
+                       return -1;
 +              }
  
 -              if(me->mcol)
 -                      CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name);
 -              else
 +              if(me->mloopcol) {
 +                      CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name);
 +                      CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mloopcol, me->totface, name);
 +              }
 +              else {
 +                      CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, name);
                        CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name);
 +              }
  
 -              if(active_set || layernum==0)
 +              if(active_set || layernum==0) {
 +                      CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
                        CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
 +              }
  
 -              mesh_update_customdata_pointers(me);
 +              mesh_update_customdata_pointers(me, TRUE);
        }
  
        DAG_id_tag_update(&me->id, 0);
  
  #include <stdlib.h>
  
 +#include "MEM_guardedalloc.h"
 +
+ #include "RNA_access.h"
  #include "RNA_define.h"
 +#include "RNA_types.h"
  
  #include "rna_internal.h"
  
@@@ -1126,25 -1129,29 +1127,29 @@@ static int rna_Mesh_tot_edge_get(Pointe
  }
  static int rna_Mesh_tot_face_get(PointerRNA *ptr)
  {
 -      Mesh *me= (Mesh*)ptr->id.data;
 -      return me->edit_mesh ? me->edit_mesh->totfacesel : 0;
 +      Mesh *me = rna_mesh(ptr);
 +      return me->edit_btmesh ? me->edit_btmesh->bm->totfacesel : 0;
  }
  
- static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
  {
-       CustomData *ldata = rna_mesh_ldata_helper(me);
+       PointerRNA ptr;
 -      CustomData *fdata;
++      CustomData *ldata;
        CustomDataLayer *cdl= NULL;
-       int index;
+       int index= ED_mesh_color_add(C, NULL, NULL, me, name, FALSE);
  
-       if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) {
-               index= CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name);
-               cdl= (index == -1)? NULL: &ldata->layers[index];
+       if(index != -1) {
 -              fdata= rna_mesh_fdata(me);
 -              cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)];
++              ldata= rna_mesh_ldata_helper(me);
++              cdl= &ldata->layers[CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, index)];
        }
-       return cdl;
 -      RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr);
++      RNA_pointer_create(&me->id, &RNA_MeshLoopColorLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomDataLayer *cdl = NULL;
        int index;
  
@@@ -1179,20 -1190,24 +1188,24 @@@ static PointerRNA rna_Mesh_string_prope
  
        cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
  
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshStringPropertyLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
  {
-       CustomData *pdata = rna_mesh_pdata_helper(me);
+       PointerRNA ptr;
 -      CustomData *fdata;
++      CustomData *pdata;
        CustomDataLayer *cdl= NULL;
-       int index;
 -      int index= ED_mesh_uv_texture_add(C, me, name, FALSE);
++      int index = ED_mesh_uv_texture_add(C, me, name, FALSE);
  
-       if(ED_mesh_uv_texture_add(C, me, name, FALSE)) {
-               index= CustomData_get_named_layer_index(pdata, CD_MTEXPOLY, name);
-               cdl= (index == -1)? NULL: &pdata->layers[index];
+       if(index != -1) {
 -              fdata= rna_mesh_fdata(me);
 -              cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)];
++              pdata= rna_mesh_pdata_helper(me);
++              cdl= &pdata->layers[CustomData_get_layer_index_n(pdata, CD_MTEXPOLY, index)];
        }
-       return cdl;
 -      RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr);
++      RNA_pointer_create(&me->id, &RNA_MeshTexturePolyLayer, cdl, &ptr);
+       return ptr;
  }
  
  #else
@@@ -2007,7 -1748,7 +2020,7 @@@ static void rna_def_mesh_faces(BlenderR
        PropertyRNA *prop;
  
        FunctionRNA *func;
-       PropertyRNA *parm;
 -      /*PropertyRNA *parm;*/
++//    PropertyRNA *parm;
  
        RNA_def_property_srna(cprop, "MeshFaces");
        srna= RNA_def_struct(brna, "MeshFaces", NULL);
@@@ -2122,7 -1793,8 +2135,8 @@@ static void rna_def_loop_colors(Blender
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
        RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
        RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
 -      parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer");
 +      parm= RNA_def_pointer(func, "layer", "MeshLoopColorLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
        
  /*
@@@ -2276,9 -1899,10 +2293,10 @@@ static void rna_def_uv_textures(Blender
        
        func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 -      RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh");
 +      RNA_def_function_ui_description(func, "Add a UV map layer to Mesh");
        RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
 -      parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer");
 +      parm= RNA_def_pointer(func, "layer", "MeshTexturePolyLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
  
  /*