diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-29 17:44:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-29 17:44:30 +0400 |
commit | 20e233043470c05fce0e1b78fbce141a8275133c (patch) | |
tree | 3417beebcbb0ac3c6b9a0e2ecbeb5ec173243962 | |
parent | f87c5b3453a779ebe96afff734c0ca6da1a03f8d (diff) |
added Mesh.calc_tessface(), needed to update mesh tessface after bmesh edits.
also add py api BMDeformVert.clear()
-rw-r--r-- | doc/python_api/rst/include__bmesh.rst | 10 | ||||
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh_api.c | 3 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_meshdata.c | 17 |
5 files changed, 40 insertions, 1 deletions
diff --git a/doc/python_api/rst/include__bmesh.rst b/doc/python_api/rst/include__bmesh.rst index 82cc525ecb7..24f113e7b50 100644 --- a/doc/python_api/rst/include__bmesh.rst +++ b/doc/python_api/rst/include__bmesh.rst @@ -75,6 +75,16 @@ its good practice to call :class:`bmesh.types.BMesh.free` which will remove all further access. +EditMode Tessellation +^^^^^^^^^^^^^^^^^^^^^ + +When writing scripts that operate on editmode data you will normally want to re-calculate the tessellation after +running the script, this needs to be called explicitly. + +The BMesh its self does not store the triangulated faces, they are stored in the :class:`bpy.types.Mesh`, +to refresh tessellation faces call :class:`bpy.types.Mesh.calc_tessface`. + + CustomData Access ----------------- diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 5b61fc01645..0ab9c5dd977 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -261,6 +261,7 @@ void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int void ED_mesh_transform(struct Mesh *me, float *mat); void ED_mesh_calc_normals(struct Mesh *me); +void ED_mesh_calc_tessface(struct Mesh *mesh); 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 calc_tessface); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 0ede2baf9f6..69aeee48a4b 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -1182,3 +1182,13 @@ void ED_mesh_calc_normals(Mesh *mesh) NULL); #endif } + +void ED_mesh_calc_tessface(Mesh *mesh) +{ + if (mesh->edit_btmesh) { + BMEdit_RecalcTessellation(mesh->edit_btmesh); + } + else { + BKE_mesh_tessface_calc(mesh); + } +} diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index c6aea38b55c..41b232fdf8b 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -65,6 +65,9 @@ void RNA_api_mesh(StructRNA *srna) 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, "calc_tessface", "ED_mesh_calc_tessface"); + RNA_def_function_ui_description(func, "Calculate face tessellation (supports editmode too)"); + func = RNA_def_function(srna, "update", "ED_mesh_update"); RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges"); RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces"); diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index db8cc24ff0c..9972ff288b2 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -525,12 +525,26 @@ static PyObject *bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args) } } + +PyDoc_STRVAR(bpy_bmdeformvert_clear_doc, +".. method:: clear()\n" +"\n" +" Clears all weights.\n" +); +static PyObject *bpy_bmdeformvert_clear(BPy_BMDeformVert *self) +{ + defvert_clear(self->data); + + Py_RETURN_NONE; +} + static struct PyMethodDef bpy_bmdeformvert_methods[] = { {"keys", (PyCFunction)bpy_bmdeformvert_keys, METH_NOARGS, bpy_bmdeformvert_keys_doc}, {"values", (PyCFunction)bpy_bmdeformvert_values, METH_NOARGS, bpy_bmdeformvert_values_doc}, {"items", (PyCFunction)bpy_bmdeformvert_items, METH_NOARGS, bpy_bmdeformvert_items_doc}, {"get", (PyCFunction)bpy_bmdeformvert_get, METH_VARARGS, bpy_bmdeformvert_get_doc}, - /* BMESH_TODO */ + /* BMESH_TODO pop, popitem, update */ + {"clear", (PyCFunction)bpy_bmdeformvert_clear, METH_NOARGS, bpy_bmdeformvert_clear_doc}, {NULL, NULL, 0, NULL} }; @@ -586,3 +600,4 @@ void BPy_BM_init_types_meshdata(void) bm_init_types_bmloopcol(); bm_init_types_bmdvert(); } + |