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
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-03-13 10:44:43 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-03-13 10:44:43 +0400
commit894c240f9d007271e9d587d3c1b6f961c445b1b8 (patch)
tree369079e17a0c80a5b39e323a67045ca397849491 /source/blender/python/bmesh/bmesh_py_types.c
parent2d801f2bec3c4de663f33b0f0f198a12f09ef989 (diff)
New implementation of Freestyle edge/face marks
The previous implementation of Freestyle edge/face marks was refactored based on suggestions from the latest code review by Campbell. The new implementation relies on mesh CustomData to store edge/face marks, instead of introducing extra flags in the core Mesh and BMesh data structures. The CustomData-based implementation will allow further additions of new edge/face attributes because of the independence from Mesh/BMesh. This revision is work in progress, mainly intended to address the review comments and ask for further code review in view of the trunk merger in the upcoming 2.67 release.
Diffstat (limited to 'source/blender/python/bmesh/bmesh_py_types.c')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c95
1 files changed, 85 insertions, 10 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index b95db945eb1..052496e3ed7 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -84,9 +84,6 @@ PyC_FlagSet bpy_bm_hflag_all_flags[] = {
{BM_ELEM_SEAM, "SEAM"},
{BM_ELEM_SMOOTH, "SMOOTH"},
{BM_ELEM_TAG, "TAG"},
-#ifdef WITH_FREESTYLE
- {BM_ELEM_FREESTYLE, "FREESTYLE"},
-#endif
{0, NULL}
};
@@ -106,11 +103,6 @@ PyDoc_STRVAR(bpy_bm_elem_tag_doc, "Generic attribute scripts can use for own
PyDoc_STRVAR(bpy_bm_elem_smooth_doc, "Smooth state of this element.\n\n:type: boolean");
PyDoc_STRVAR(bpy_bm_elem_seam_doc, "Seam for UV unwrapping.\n\n:type: boolean");
-#ifdef WITH_FREESTYLE
-PyDoc_STRVAR(bpy_bm_freestyle_edge_mark_doc, "Freestyle edge mark.\n\n:type: boolean");
-PyDoc_STRVAR(bpy_bm_freestyle_face_mark_doc, "Freestyle face mark.\n\n:type: boolean");
-#endif
-
static PyObject *bpy_bm_elem_hflag_get(BPy_BMElem *self, void *flag)
{
const char hflag = (char)GET_INT_FROM_POINTER(flag);
@@ -449,6 +441,47 @@ static PyObject *bpy_bmedge_is_boundary_get(BPy_BMEdge *self)
return PyBool_FromLong(BM_edge_is_boundary(self->e));
}
+#ifdef WITH_FREESTYLE
+PyDoc_STRVAR(bpy_bmedge_freestyle_edge_mark_doc,
+"Freestyle edge mark.\n\n:type: boolean"
+);
+static PyObject *bpy_bmedge_freestyle_edge_mark_get(BPy_BMEdge *self)
+{
+ FreestyleEdge *fed;
+
+ BPY_BM_CHECK_OBJ(self);
+ fed = CustomData_bmesh_get(&self->bm->edata, self->e->head.data, CD_FREESTYLE_EDGE);
+ return PyBool_FromLong(fed->flag & FREESTYLE_EDGE_MARK);
+}
+
+static int bpy_bmedge_freestyle_edge_mark_set(BPy_BMEdge *self, PyObject *value)
+{
+ int param;
+ FreestyleEdge *fed;
+
+ BPY_BM_CHECK_INT(self);
+
+ param = PyLong_AsLong(value);
+ if (param != false && param != true) {
+ PyErr_SetString(PyExc_TypeError,
+ "expected a boolean type 0/1");
+ return -1;
+ }
+
+ if (!CustomData_has_layer(&self->bm->edata, CD_FREESTYLE_EDGE)) {
+ BM_data_layer_add(self->bm, &self->bm->edata, CD_FREESTYLE_EDGE);
+ }
+
+ fed = CustomData_bmesh_get(&self->bm->edata, self->e->head.data, CD_FREESTYLE_EDGE);
+ if (param)
+ fed->flag &= ~FREESTYLE_EDGE_MARK;
+ else
+ fed->flag |= FREESTYLE_EDGE_MARK;
+
+ return 0;
+}
+#endif
+
/* Face
* ^^^^ */
@@ -508,6 +541,48 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value)
}
}
+#ifdef WITH_FREESTYLE
+PyDoc_STRVAR(bpy_bmface_freestyle_face_mark_doc,
+"Freestyle face mark.\n\n:type: boolean"
+);
+static PyObject *bpy_bmface_freestyle_face_mark_get(BPy_BMFace *self)
+{
+ FreestyleFace *ffa;
+
+ BPY_BM_CHECK_OBJ(self);
+ ffa = CustomData_bmesh_get(&self->bm->pdata, self->f->head.data, CD_FREESTYLE_FACE);
+ return PyBool_FromLong(ffa->flag & FREESTYLE_FACE_MARK);
+}
+
+static int bpy_bmface_freestyle_face_mark_set(BPy_BMFace *self, PyObject *value)
+{
+ int param;
+ FreestyleFace *ffa;
+
+ BPY_BM_CHECK_INT(self);
+
+ param = PyLong_AsLong(value);
+ if (param != false && param != true) {
+ PyErr_SetString(PyExc_TypeError,
+ "expected a boolean type 0/1");
+ return -1;
+ }
+
+ if (!CustomData_has_layer(&self->bm->pdata, CD_FREESTYLE_FACE)) {
+ BM_data_layer_add(self->bm, &self->bm->pdata, CD_FREESTYLE_FACE);
+ }
+
+ ffa = CustomData_bmesh_get(&self->bm->pdata, self->f->head.data, CD_FREESTYLE_FACE);
+ if (param)
+ ffa->flag &= ~FREESTYLE_FACE_MARK;
+ else
+ ffa->flag |= FREESTYLE_FACE_MARK;
+
+ return 0;
+}
+#endif
+
+
/* Loop
* ^^^^ */
@@ -689,7 +764,7 @@ static PyGetSetDef bpy_bmedge_getseters[] = {
{(char *)"seam", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM},
#ifdef WITH_FREESTYLE
- {(char *)"freestyle_edge_mark", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_freestyle_edge_mark_doc, (void *)BM_ELEM_FREESTYLE},
+ {(char *)"freestyle_edge_mark", (getter)bpy_bmedge_freestyle_edge_mark_get, (setter)bpy_bmedge_freestyle_edge_mark_set, (char *)bpy_bmedge_freestyle_edge_mark_doc, NULL},
#endif
/* connectivity data */
@@ -718,7 +793,7 @@ static PyGetSetDef bpy_bmface_getseters[] = {
{(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
#ifdef WITH_FREESTYLE
- {(char *)"freestyle_face_mark", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_freestyle_face_mark_doc, (void *)BM_ELEM_FREESTYLE},
+ {(char *)"freestyle_face_mark", (getter)bpy_bmface_freestyle_face_mark_get, (setter)bpy_bmface_freestyle_face_mark_set, (char *)bpy_bmface_freestyle_face_mark_doc, NULL},
#endif
{(char *)"normal", (getter)bpy_bmface_normal_get, (setter)bpy_bmface_normal_set, (char *)bpy_bmface_normal_doc, NULL},