Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-27 02:44:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-27 02:44:05 +0400
commit50bce31dbbf727cef0746a16bb5a669c30b21628 (patch)
treed08f303ee0af24cab2f3dddd304283a7234304c3 /source
parent9089b68073ab474c664078dcfeb1fb49ef6e3caf (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')
-rw-r--r--source/blender/editors/include/ED_mesh.h7
-rw-r--r--source/blender/editors/mesh/mesh_data.c42
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c77
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c16
-rw-r--r--source/blender/python/intern/bpy_rna.c4
5 files changed, 115 insertions, 31 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);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index aff6d7d5697..659e08a1878 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1630,14 +1630,52 @@ static void rna_def_mproperties(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
-/* scene.objects */
+/* mesh.vertices */
+static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+// PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "MeshVertices");
+ srna= RNA_def_struct(brna, "MeshVertices", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Mesh Vertices", "Collection of mesh vertices");
+
+ func= RNA_def_function(srna, "add", "ED_mesh_vertices_add");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX);
+}
+
+/* mesh.edges */
+static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+// PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "MeshEdges");
+ srna= RNA_def_struct(brna, "MeshEdges", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Mesh Edges", "Collection of mesh edges");
+
+ func= RNA_def_function(srna, "add", "ED_mesh_edges_add");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX);
+}
+
+/* mesh.faces */
static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
-// FunctionRNA *func;
-// PropertyRNA *parm;
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "MeshFaces");
srna= RNA_def_struct(brna, "MeshFaces", NULL);
@@ -1653,8 +1691,11 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_mtface_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Active Texture Face", "Active Texture Face");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-}
+ func= RNA_def_function(srna, "add", "ED_mesh_faces_add");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX);
+}
/* mesh.vertex_colors */
static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1738,6 +1779,29 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
+/* mesh.materials */
+static void rna_def_mesh_materials(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ // PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "MeshMaterials");
+ srna= RNA_def_struct(brna, "MeshMaterials", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Mesh Materials", "Collection of materials");
+
+ func= RNA_def_function(srna, "link", "ED_mesh_material_link");
+ RNA_def_function_ui_description(func, "Add a new material to Mesh.");
+ parm= RNA_def_pointer(func, "material", "Material", "", "Material to add.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
+ /* TODO, unlink? */
+}
+
+
static void rna_def_mesh(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1751,11 +1815,13 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
RNA_def_property_struct_type(prop, "MeshVertex");
RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh");
+ rna_def_mesh_vertices(brna, prop);
prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge");
RNA_def_property_struct_type(prop, "MeshEdge");
RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh");
+ rna_def_mesh_edges(brna, prop);
prop= RNA_def_property(srna, "faces", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mface", "totface");
@@ -1883,7 +1949,8 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");
-
+ rna_def_mesh_materials(brna, prop);
+
/* Mesh Draw Options for Edit Mode*/
prop= RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index b0d655e611c..eaf18920c85 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -50,28 +50,12 @@ void RNA_api_mesh(StructRNA *srna)
parm= RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix.", 0.0f, 0.0f);
RNA_def_property_flag(parm, PROP_REQUIRED);
- func= RNA_def_function(srna, "add_geometry", "ED_mesh_geometry_add");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm= RNA_def_int(func, "vertices", 0, 0, INT_MAX, "Number", "Number of vertices to add.", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_int(func, "edges", 0, 0, INT_MAX, "Number", "Number of edges to add.", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_int(func, "faces", 0, 0, INT_MAX, "Number", "Number of faces to add.", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED);
-
func= RNA_def_function(srna, "calc_normals", "ED_mesh_calc_normals");
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");
- RNA_def_function_ui_description(func, "Add a new material to Mesh.");
- parm= RNA_def_pointer(func, "material", "Material", "", "Material to add.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
-
-
}
#endif
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 60d1f044cb4..8e5f70a6f58 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4703,7 +4703,9 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
fprintf(stderr, "bpy_class_call(): unable to get python class for rna struct '%.200s'\n", RNA_struct_identifier(ptr->type));
return -1;
}
-
+
+ printf("could not find function %s in %s to execute callback.\n", RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
+
bpy_context_set(C, &gilstate);
if (!is_static) {