diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-12 23:34:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-12 23:34:58 +0400 |
commit | b5f820cd874a7b3ca1de81103b99969429adfd6c (patch) | |
tree | f2bf19fa8eb0cfe1e23828f10ba845d3bb13b78a /source/blender/makesrna/intern | |
parent | 0696cf23e5561a2ac65cf5af8881748cc45b8da4 (diff) |
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.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh_api.c | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 84a1940de9d..8b67ccecc3d 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -732,6 +732,27 @@ static void rna_MeshFace_verts_set(PointerRNA *ptr, const int *values) 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 @@ static void rna_def_mvert(BlenderRNA *brna) 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 @@ static void rna_def_medge(BlenderRNA *brna) 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 @@ static void rna_def_mface(BlenderRNA *brna) 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) diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 3da0e1e6fd4..52ff98f66f0 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -72,6 +72,7 @@ void RNA_api_mesh(StructRNA *srna) 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"); |