From c9c66720c8e2722a50945e0dd09fe3027832e6a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 26 Mar 2012 04:32:04 +0000 Subject: disallow adding tessfaces to a mesh with polygons (only allowed case is creating a new mesh with tessfaces and later converting to polygons, which wont work if polygons exist) --- source/blender/editors/include/ED_mesh.h | 2 +- source/blender/editors/mesh/mesh_data.c | 13 +++++++++---- source/blender/makesrna/intern/rna_mesh.c | 10 +++++----- source/blenderplayer/bad_level_call_stubs/stubs.c | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 35bf9d77b23..45685740d3b 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -270,7 +270,7 @@ struct BMFace *EDBM_findnearestface(struct ViewContext *vc, int *dist); /* mesh_data.c */ // void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces); void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count); -void ED_mesh_faces_add(struct Mesh *mesh, struct ReportList *reports, int count); +void ED_mesh_tessfaces_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_loops_add(struct Mesh *mesh, struct ReportList *reports, int count); void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 3c54848e9ea..d3d043501dc 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -906,7 +906,7 @@ static void mesh_add_edges(Mesh *mesh, int len) mesh->totedge = totedge; } -static void mesh_add_faces(Mesh *mesh, int len) +static void mesh_add_tessfaces(Mesh *mesh, int len) { CustomData fdata; MFace *mface; @@ -1047,14 +1047,19 @@ void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, } #endif -void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count) +void ED_mesh_tessfaces_add(Mesh *mesh, ReportList *reports, int count) { if (mesh->edit_btmesh) { - BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode"); + BKE_report(reports, RPT_ERROR, "Can't add tessfaces in edit mode"); return; } - mesh_add_faces(mesh, count); + if (mesh->mpoly) { + BKE_report(reports, RPT_ERROR, "Can't add tessfaces to a mesh that already has polygons"); + return; + } + + mesh_add_tessfaces(mesh, count); } void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index ad5b72079a9..5a724526960 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2143,7 +2143,7 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) } /* mesh.faces */ -static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_mesh_tessfaces(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; PropertyRNA *prop; @@ -2151,8 +2151,8 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) FunctionRNA *func; /* PropertyRNA *parm; */ - RNA_def_property_srna(cprop, "MeshFaces"); - srna = RNA_def_struct(brna, "MeshFaces", NULL); + RNA_def_property_srna(cprop, "MeshTessFaces"); + srna = RNA_def_struct(brna, "MeshTessFaces", NULL); RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "Mesh Faces", "Collection of mesh faces"); @@ -2160,7 +2160,7 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_int_sdna(prop, NULL, "act_face"); RNA_def_property_ui_text(prop, "Active Face", "The active face for this mesh"); - func = RNA_def_function(srna, "add", "ED_mesh_faces_add"); + func = RNA_def_function(srna, "add", "ED_mesh_tessfaces_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX); #if 0 /* BMESH_TODO Remove until BMesh merge */ @@ -2496,7 +2496,7 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mface", "totface"); RNA_def_property_struct_type(prop, "MeshTessFace"); RNA_def_property_ui_text(prop, "TessFaces", "Tessellation faces of the mesh (derived from polygons)"); - rna_def_mesh_faces(brna, prop); + rna_def_mesh_tessfaces(brna, prop); prop = RNA_def_property(srna, "loops", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mloop", "totloop"); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 715eb3b58b5..cff4d34e344 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -324,7 +324,7 @@ void ED_mesh_transform(struct Mesh *me, float *mat){} void ED_mesh_update(struct Mesh *mesh, struct bContext *C){} void ED_mesh_vertices_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_faces_add(struct Mesh *mesh, struct ReportList *reports, int count){} +void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count){} void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count){} void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count){} void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count){} -- cgit v1.2.3