[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44399] trunk/blender/source/blender: bmesh py api - bmesh.utils.face_flip

Campbell Barton ideasman42 at gmail.com
Fri Feb 24 12:04:17 CET 2012


Revision: 44399
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44399
Author:   campbellbarton
Date:     2012-02-24 11:04:09 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
bmesh py api - bmesh.utils.face_flip

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
    trunk/blender/source/blender/makesrna/intern/rna_define.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-02-24 10:40:32 UTC (rev 44398)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-02-24 11:04:09 UTC (rev 44399)
@@ -610,27 +610,6 @@
 
 /* detects if two line segments cross each other (intersects).
  * note, there could be more winding cases then there needs to be. */
-static int UNUSED_FUNCTION(linecrosses)(const double v1[2], const double v2[2], const double v3[2], const double v4[2])
-{
-	int w1, w2, w3, w4, w5;
-	
-	/* w1 = winding(v1, v3, v4);
-	w2 = winding(v2, v3, v4);
-	w3 = winding(v3, v1, v2);
-	w4 = winding(v4, v1, v2);
-	
-	return (w1 == w2) && (w3 == w4); */
-
-	w1 = testedgeside(v1, v3, v2);
-	w2 = testedgeside(v2, v4, v1);
-	w3 = !testedgeside(v1, v2, v3);
-	w4 = testedgeside(v3, v2, v4);
-	w5 = !testedgeside(v3, v1, v4);
-	return w1 == w2 && w2 == w3 && w3 == w4 && w4 == w5;
-}
-
-/* detects if two line segments cross each other (intersects).
- * note, there could be more winding cases then there needs to be. */
 static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 {
 	int w1, w2, w3, w4, w5 /*, re */;

Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-02-24 10:40:32 UTC (rev 44398)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-02-24 11:04:09 UTC (rev 44399)
@@ -2666,7 +2666,7 @@
 			case PROP_FLOAT:
 				return sizeof(float);
 			case PROP_STRING:
-				/* return  valyes dont store a pointer to the original */
+				/* return values don't store a pointer to the original */
 				if(parm->flag & PROP_THICK_WRAP) {
 					StringPropertyRNA *sparm= (StringPropertyRNA*)parm;
 					return sizeof(char) * sparm->maxlength;

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c	2012-02-24 10:40:32 UTC (rev 44398)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c	2012-02-24 11:04:09 UTC (rev 44399)
@@ -47,11 +47,11 @@
 "   Collapse a vertex into an edge.\n"
 "\n"
 "   :arg vert: The vert that will be collapsed.\n"
-"   :type vert: :class:`bmesh.types.BMVert`\n"
+"   :type vert: :class:`BMVert`\n"
 "   :arg edge: The edge to collapse into.\n"
-"   :type edge: :class:`bmesh.types.BMEdge`\n"
+"   :type edge: :class:`BMEdge`\n"
 "   :return: The resulting edge from the collapse operation.\n"
-"   :rtype: :class:`bmesh.types.BMEdge`\n"
+"   :rtype: :class:`BMEdge`\n"
 );
 static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObject *args)
 {
@@ -107,13 +107,13 @@
 "   Split an edge, return the newly created data.\n"
 "\n"
 "   :arg vert: The vert that will be collapsed.\n"
-"   :type vert: :class:`bmesh.types.BMVert`\n"
+"   :type vert: :class:`BMVert`\n"
 "   :arg edge: The edge to collapse into.\n"
-"   :type edge: :class:`bmesh.types.BMEdge`\n"
+"   :type edge: :class:`BMEdge`\n"
 "   :arg fac: The factor to use when merging customdata [0 - 1].\n"
 "   :type fac: float\n"
 "   :return: The resulting edge from the collapse operation.\n"
-"   :rtype: :class:`bmesh.types.BMEdge`\n"
+"   :rtype: :class:`BMEdge`\n"
 );
 static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObject *args)
 {
@@ -173,7 +173,7 @@
 "   Dissolve this vertex (will be removed).\n"
 "\n"
 "   :arg vert: The vert to be dissolved.\n"
-"   :type vert: :class:`bmesh.types.BMVert`\n"
+"   :type vert: :class:`BMVert`\n"
 "   :return: True when the vertex dissolve is successful.\n"
 "   :rtype: boolean\n"
 );
@@ -203,9 +203,9 @@
 "   Split an edge, return the newly created data.\n"
 "\n"
 "   :arg edge: The edge to split.\n"
-"   :type edge: :class:`bmesh.types.BMEdge`\n"
+"   :type edge: :class:`BMEdge`\n"
 "   :arg vert: One of the verts on the edge, defines the split direction.\n"
-"   :type vert: :class:`bmesh.types.BMVert`\n"
+"   :type vert: :class:`BMVert`\n"
 "   :arg fac: The point on the edge where the new vert will be created [0 - 1].\n"
 "   :type fac: float\n"
 "   :return: The newly created (edge, vert) pair.\n"
@@ -266,11 +266,11 @@
 "   If rotating the edge fails, None will be returned.\n"
 "\n"
 "   :arg edge: The edge to rotate.\n"
-"   :type edge: :class:`bmesh.types.BMEdge`\n"
+"   :type edge: :class:`BMEdge`\n"
 "   :arg ccw: When True the edge will be rotated counter clockwise.\n"
 "   :type ccw: boolean\n"
 "   :return: The newly rotated edge.\n"
-"   :rtype: :class:`bmesh.types.BMEdge`\n"
+"   :rtype: :class:`BMEdge`\n"
 );
 static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args)
 {
@@ -308,13 +308,13 @@
 "   Split an edge, return the newly created data.\n"
 "\n"
 "   :arg face: The face to cut.\n"
-"   :type face: :class:`bmesh.types.BMFace`\n"
+"   :type face: :class:`BMFace`\n"
 "   :arg vert_a: First vertex to cut in the face (face must contain the vert).\n"
-"   :type vert_a: :class:`bmesh.types.BMVert`\n"
+"   :type vert_a: :class:`BMVert`\n"
 "   :arg vert_b: Second vertex to cut in the face (face must contain the vert).\n"
-"   :type vert_b: :class:`bmesh.types.BMVert`\n"
+"   :type vert_b: :class:`BMVert`\n"
 "   :arg edge_example: Optional edge argument, newly created edge will copy settings from this one.\n"
-"   :type edge_example: :class:`bmesh.types.BMEdge`\n"
+"   :type edge_example: :class:`BMEdge`\n"
 );
 static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args)
 {
@@ -378,15 +378,16 @@
 	}
 }
 
+
 PyDoc_STRVAR(bpy_bm_utils_face_join_doc,
 ".. method:: face_join(faces)\n"
 "\n"
 "   Joins a sequence of faces.\n"
 "\n"
-"   :arg faces: Sequence of faces .\n"
-"   :type faces: :class:`bmesh.types.BMFace`\n"
+"   :arg faces: Sequence of faces.\n"
+"   :type faces: :class:`BMFace`\n"
 "   :return: The newly created face or None on failure.\n"
-"   :rtype: :class:`bmesh.types.BMFace`\n"
+"   :rtype: :class:`BMFace`\n"
 );
 static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *value)
 {
@@ -415,6 +416,32 @@
 	}
 }
 
+
+PyDoc_STRVAR(bpy_bm_utils_face_flip_doc,
+".. method:: face_flip(faces)\n"
+"\n"
+"   Flip the faces direction.\n"
+"\n"
+"   :arg face: Face to flip.\n"
+"   :type face: :class:`BMFace`\n"
+);
+static PyObject *bpy_bm_utils_face_flip(PyObject *UNUSED(self), BPy_BMFace *value)
+{
+	if (!BPy_BMFace_Check(value)) {
+		PyErr_Format(PyExc_TypeError,
+		             "face_flip(face): BMFace expected, not '%.200s'",
+		             Py_TYPE(value)->tp_name);
+		return NULL;
+	}
+
+	BPY_BM_CHECK_OBJ(value);
+
+	BM_face_normal_flip(value->bm, value->f);
+
+	Py_RETURN_NONE;
+}
+
+
 static struct PyMethodDef BPy_BM_utils_methods[] = {
     {"vert_collapse_edge",  (PyCFunction)bpy_bm_utils_vert_collapse_edge,  METH_VARARGS, bpy_bm_utils_vert_collapse_edge_doc},
     {"vert_collapse_faces", (PyCFunction)bpy_bm_utils_vert_collapse_faces, METH_VARARGS, bpy_bm_utils_vert_collapse_faces_doc},
@@ -423,13 +450,14 @@
     {"edge_rotate",         (PyCFunction)bpy_bm_utils_edge_rotate,         METH_VARARGS, bpy_bm_utils_edge_rotate_doc},
     {"face_split",          (PyCFunction)bpy_bm_utils_face_split,          METH_VARARGS, bpy_bm_utils_face_split_doc},
     {"face_join",           (PyCFunction)bpy_bm_utils_face_join,           METH_O,       bpy_bm_utils_face_join_doc},
+    {"face_flip",           (PyCFunction)bpy_bm_utils_face_flip,           METH_O,       bpy_bm_utils_face_flip_doc},
     {NULL, NULL, 0, NULL}
 };
 
 
 PyDoc_STRVAR(BPy_BM_doc,
-             "This module provides access to blenders bmesh data structures."
-             );
+"This module provides access to blenders bmesh data structures."
+);
 static struct PyModuleDef BPy_BM_types_module_def = {
     PyModuleDef_HEAD_INIT,
     "bmesh.utils",  /* m_name */




More information about the Bf-blender-cvs mailing list