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:
authorCampbell Barton <ideasman42@gmail.com>2007-08-09 17:34:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-08-09 17:34:44 +0400
commit9776f489e6e205b0e0dd744764211ddb89037e65 (patch)
tree87ffdbc9f7777a83b41c7fafd6eb7c719035a83f /source/blender/python/api2_2x/Mesh.c
parentc66acd3c9a0a5214442b5f4cc3ccf070203b06fd (diff)
Mesh.c - getVertFromGroup ~25% speedup.
export_fbx.py - initial support for bones applied to weighted meshes.
Diffstat (limited to 'source/blender/python/api2_2x/Mesh.c')
-rw-r--r--source/blender/python/api2_2x/Mesh.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index 21a01e0d983..0463a75ec54 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -6515,7 +6515,6 @@ static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
PyObject *vertexList;
Object *object;
Mesh *mesh;
- PyObject *tempVertexList;
int num = 0;
int weightRet = 0;
@@ -6554,15 +6553,14 @@ static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"no deform groups assigned to mesh" );
- /* temporary list */
- tempVertexList = PyList_New( mesh->totvert );
- if( !tempVertexList )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "getVertsFromGroup: can't create pylist!" );
-
count = 0;
if( !listObject ) { /* do entire group */
+ vertexList = PyList_New( mesh->totvert );
+ if( !vertexList )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "getVertsFromGroup: can't create pylist!" );
+
dvert = mesh->dvert;
for( num = 0; num < mesh->totvert; num++, ++dvert ) {
for( i = 0; i < dvert->totweight; i++ ) {
@@ -6573,23 +6571,31 @@ static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
dvert->dw[i].weight );
else
attr = PyInt_FromLong ( num );
- PyList_SetItem( tempVertexList, count, attr );
+ PyList_SetItem( vertexList, count, attr );
count++;
}
}
}
+
+ if (count < mesh->totvert)
+ PyList_SetSlice(vertexList, count, mesh->totvert, NULL);
+
} else { /* do individual vertices */
- for( i = 0; i < PyList_Size( listObject ); i++ ) {
+ int listObjectLen = PyList_Size( listObject );
+
+ vertexList = PyList_New( listObjectLen );
+ for( i = 0; i < listObjectLen; i++ ) {
PyObject *attr = NULL;
- if( !PyArg_Parse( PyList_GetItem( listObject, i ), "i", &num ) ) {
- Py_DECREF(tempVertexList);
+ num = PyInt_AsLong( PyList_GetItem( listObject, i ) );
+ if (num == -1) {/* -1 is an error AND an invalid range, we dont care which */
+ Py_DECREF(vertexList);
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list integer not parseable" );
}
if( num < 0 || num >= mesh->totvert ) {
- Py_DECREF(tempVertexList);
+ Py_DECREF(vertexList);
return EXPP_ReturnPyObjError( PyExc_ValueError,
"bad vertex index in list" );
}
@@ -6601,17 +6607,15 @@ static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
dvert->dw[k].weight );
else
attr = PyInt_FromLong ( num );
- PyList_SetItem( tempVertexList, count, attr );
+ PyList_SetItem( vertexList, count, attr );
count++;
}
}
}
+ if (count < listObjectLen)
+ PyList_SetSlice(vertexList, count, listObjectLen, NULL);
}
- /* only return what we need */
- vertexList = PyList_GetSlice( tempVertexList, 0, count );
-
- Py_DECREF( tempVertexList );
-
+
return vertexList;
}