diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 02:44:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 02:44:05 +0400 |
commit | 50bce31dbbf727cef0746a16bb5a669c30b21628 (patch) | |
tree | d08f303ee0af24cab2f3dddd304283a7234304c3 /source/blender/editors | |
parent | 9089b68073ab474c664078dcfeb1fb49ef6e3caf (diff) |
rna api changes
- mesh.add_geometry(v, e, f) --> mesh.vertices.add(tot), mesh.edges.add(tot), mesh.faces.add(tot)
- mesh.add_material(mat) --> mesh.materials.link(mat)
changed material.link so it always adds a material even if it exists in the list, this behavior is good for users but not scripts since it can mess up indicies (some formats may have the same material set twice).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 7 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 42 |
2 files changed, 40 insertions, 9 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index bf809d39fe4..564fe04ca4d 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -209,11 +209,14 @@ int editface_containsEdge(struct EditFace *efa, struct EditEdge *eed); short sharesFace(struct EditMesh *em, struct EditEdge *e1, struct EditEdge *e2); /* mesh_data.c */ +// void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces); +void ED_mesh_faces_add(struct Mesh *mesh, struct ReportList *reports, int count); +void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count); +void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count); -void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces); 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_material_link(struct Mesh *me, struct Material *ma); 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, const char *name, int active_set); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index edcdedf2a39..35cb9f02b64 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -721,6 +721,7 @@ static void mesh_add_faces(Mesh *mesh, int len) mesh->totface= totface; } +/* void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces) { if(mesh->edit_mesh) { @@ -735,23 +736,50 @@ void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, if(faces) mesh_add_faces(mesh, faces); } +*/ + +void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count) +{ + if(mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode."); + return; + } + + mesh_add_faces(mesh, count); +} + +void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) +{ + if(mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode."); + return; + } + + mesh_add_edges(mesh, count); +} + +void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count) +{ + if(mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode."); + return; + } + + mesh_add_verts(mesh, count); +} void ED_mesh_calc_normals(Mesh *me) { mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } -void ED_mesh_material_add(Mesh *me, Material *ma) +/* always adds the material even if its linked alredy + * for pradictable material indicies */ +void ED_mesh_material_link(Mesh *me, Material *ma) { - int i; int totcol = me->totcol + 1; Material **mat; - /* don't add if mesh already has it */ - for(i = 0; i < me->totcol; i++) - if(me->mat[i] == ma) - return; - mat= MEM_callocN(sizeof(void*)*totcol, "newmatar"); if(me->totcol) memcpy(mat, me->mat, sizeof(void*) * me->totcol); |