Revision: 23793
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23793
Author:   campbellbarton
Date:     2009-10-12 21:34:58 +0200 (Mon, 12 Oct 2009)

Log Message:
-----------
added rna api MVert,MFace & MEdge index properties
eg.
 for v in me.verts: print(v.index)

added calc_edges as an option eg.
  mesh.update(calc_edges=True)

This is needed when adding faces to an existing mesh which create new edges.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/mesh_data.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h      2009-10-12 
19:19:29 UTC (rev 23792)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h      2009-10-12 
19:34:58 UTC (rev 23793)
@@ -195,7 +195,7 @@
 void ED_mesh_transform(struct Mesh *me, float *mat);
 void ED_mesh_calc_normals(struct Mesh *me);
 void ED_mesh_material_add(struct Mesh *me, struct Material *ma);
-void ED_mesh_update(struct Mesh *mesh, struct bContext *C);
+void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges);
 
 int ED_mesh_uv_texture_add(struct bContext *C, struct Scene *scene, struct 
Object *ob, struct Mesh *me);
 int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct 
Mesh *me);

Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c       2009-10-12 
19:19:29 UTC (rev 23792)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c       2009-10-12 
19:34:58 UTC (rev 23793)
@@ -504,9 +504,9 @@
        BLI_edgehash_free(eh, NULL);
 }
 
-void ED_mesh_update(Mesh *mesh, bContext *C)
+void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
 {
-       if(mesh->totface && mesh->totedge == 0)
+       if(calc_edges || (mesh->totface && mesh->totedge == 0))
                mesh_calc_edges(mesh);
 
        mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, 
mesh->totface, NULL);

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c     2009-10-12 
19:19:29 UTC (rev 23792)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c     2009-10-12 
19:34:58 UTC (rev 23793)
@@ -732,6 +732,27 @@
        memcpy(&face->v1, values, (face->v4 ? 4 : 3) * sizeof(int));
 }
 
+static int rna_MeshVertex_index_get(PointerRNA *ptr)
+{
+       Mesh *me= (Mesh*)ptr->id.data;
+       MVert *vert= (MVert*)ptr->data;
+       return (int)(vert - me->mvert);
+}
+
+static int rna_MeshEdge_index_get(PointerRNA *ptr)
+{
+       Mesh *me= (Mesh*)ptr->id.data;
+       MEdge *edge= (MEdge*)ptr->data;
+       return (int)(edge - me->medge);
+}
+
+static int rna_MeshFace_index_get(PointerRNA *ptr)
+{
+       Mesh *me= (Mesh*)ptr->id.data;
+       MFace *face= (MFace*)ptr->data;
+       return (int)(face - me->mface);
+}
+
 /* path construction */
 
 static char *rna_VertexGroupElement_path(PointerRNA *ptr)
@@ -905,6 +926,11 @@
        RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", 
"rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 
0, 0, 0, 0, 0);
        RNA_def_property_struct_type(prop, "VertexGroupElement");
        RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups 
this vertex is member of.");
+
+       prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_int_funcs(prop, "rna_MeshVertex_index_get", NULL, 
NULL);
+       RNA_def_property_ui_text(prop, "Index", "Index number of the vertex.");
 }
 
 static void rna_def_medge(BlenderRNA *brna)
@@ -963,6 +989,11 @@
        RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FGON);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Fgon", "Fgon edge");
+
+       prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_int_funcs(prop, "rna_MeshEdge_index_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Index", "Index number of the vertex.");
 }
 
 static void rna_def_mface(BlenderRNA *brna)
@@ -1017,6 +1048,11 @@
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_float_funcs(prop, "rna_MeshFace_normal_get", NULL, 
NULL);
        RNA_def_property_ui_text(prop, "face normal", "local space unit length 
normal vector for this face");
+
+       prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_int_funcs(prop, "rna_MeshFace_index_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Index", "Index number of the vertex.");
 }
 
 static void rna_def_mtface(BlenderRNA *brna)

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c 2009-10-12 
19:19:29 UTC (rev 23792)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c 2009-10-12 
19:34:58 UTC (rev 23793)
@@ -72,6 +72,7 @@
        RNA_def_function_ui_description(func, "Calculate vertex normals.");
 
        func= RNA_def_function(srna, "update", "ED_mesh_update");
+       RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force 
recalculation of edges.");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 
        func= RNA_def_function(srna, "add_material", "ED_mesh_material_add");

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c  2009-10-12 
19:19:29 UTC (rev 23792)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c  2009-10-12 
19:34:58 UTC (rev 23793)
@@ -241,6 +241,9 @@
                        {"IntProperty", (PyCFunction)BPy_IntProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
                        {"BoolProperty", (PyCFunction)BPy_BoolProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
                        {"StringProperty", (PyCFunction)BPy_StringProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
+                       {"EnumProperty", (PyCFunction)BPy_EnumProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
+                       {"PointerProperty", (PyCFunction)BPy_PointerProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
+                       {"CollectionProperty", 
(PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""},
                        {NULL, NULL, 0, NULL}
                };
                


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to