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)

This commit is contained in:
Campbell Barton 2012-03-26 04:32:04 +00:00
parent 452f7c3868
commit c9c66720c8
4 changed files with 16 additions and 11 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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");

View File

@ -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){}