[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14250] trunk/blender/source/blender/ python/api2_2x: Python API

Ken Hughes khughes at pacific.edu
Wed Mar 26 18:29:20 CET 2008


Revision: 14250
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14250
Author:   khughes
Date:     2008-03-26 18:29:20 +0100 (Wed, 26 Mar 2008)

Log Message:
-----------
Python API
----------
Bugfix #8615: NMesh.update() did not check if faces had less than 3 vertices, so would create bogus faces.  

Also discovered in the process that documentation and error message for Mesh.assignVertsToGroup() was wrong.

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Mesh.c
    trunk/blender/source/blender/python/api2_2x/NMesh.c
    trunk/blender/source/blender/python/api2_2x/doc/Mesh.py

Modified: trunk/blender/source/blender/python/api2_2x/Mesh.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Mesh.c	2008-03-26 16:46:04 UTC (rev 14249)
+++ trunk/blender/source/blender/python/api2_2x/Mesh.c	2008-03-26 17:29:20 UTC (rev 14250)
@@ -6483,7 +6483,7 @@
 	if( !PyArg_ParseTuple ( args, "sO!fi", &groupStr, &PyList_Type,
 			&listObject, &weight, &assignmode) ) {
 		return EXPP_ReturnPyObjError( PyExc_TypeError,
-					      "expected string, list,	float, string arguments" );
+					      "expected string, list, float, int arguments" );
 	}
 
 	pGroup = get_named_vertexgroup( object, groupStr );

Modified: trunk/blender/source/blender/python/api2_2x/NMesh.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/NMesh.c	2008-03-26 16:46:04 UTC (rev 14249)
+++ trunk/blender/source/blender/python/api2_2x/NMesh.c	2008-03-26 17:29:20 UTC (rev 14250)
@@ -2582,27 +2582,27 @@
 	nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 0 );
 	if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
 		mf->v1 = nmv->index;
-	else
-		mf->v1 = 0;
+	else 
+		return -1;
 
 	nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 1 );
 	if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
 		mf->v2 = nmv->index;
 	else
-		mf->v2 = 0;
+		return -1;
 
 	nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 2 );
 	if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
 		mf->v3 = nmv->index;
 	else
-		mf->v3 = 0;
+		return -1;
 
 	if( numverts == 4 ) {
 		nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 3 );
 		if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
 			mf->v4 = nmv->index;
 		else
-			mf->v4 = 0;
+			return -1;
 	}
 
 	if( tf )
@@ -2966,6 +2966,7 @@
 	MVert *newmv;
 	MSticky *newst;
 	int nmeshtotedges;
+	int badfaces;
 	int i, j, ok;
 
 	/* Minor note: we used 'mode' because 'flag' was already used internally
@@ -3054,14 +3055,19 @@
 	}
 
 	newmf = mesh->mface;
+	badfaces = 0;
 	for( i = 0; i < mesh->totface; i++ ) {
 		PyObject *mf = PySequence_GetItem( nmesh->faces, i );
 		ok = mface_from_data( newmf, &mesh->fdata, i, ( BPy_NMFace * ) mf );
 		Py_DECREF( mf );
-		if( !ok )
+		if( ok == 0)
 			return 0;
-		newmf++;
+		else if ( ok == -1 )
+			++badfaces;
+		else
+			newmf++;
 	}
+	mesh->totface -= badfaces;
 
 		/* Always do this to ensure no loose edges in faces */
     fill_medge_from_nmesh(mesh, nmesh);

Modified: trunk/blender/source/blender/python/api2_2x/doc/Mesh.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Mesh.py	2008-03-26 16:46:04 UTC (rev 14249)
+++ trunk/blender/source/blender/python/api2_2x/doc/Mesh.py	2008-03-26 17:29:20 UTC (rev 14250)
@@ -987,7 +987,7 @@
 		@param group: the name of a vertex group.
 		"""
 
-	def assignVertsToGroup(group, vertList, weight, assignmode = AssignModes['REPLACE']):
+	def assignVertsToGroup(group, vertList, weight, assignmode):
 		"""
 		Adds an array (a Python list) of vertex points to a named vertex group
 		associated with a mesh. The vertex list is a list of vertex indices from





More information about the Bf-blender-cvs mailing list