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:
authorKen Hughes <khughes@pacific.edu>2005-11-09 03:38:56 +0300
committerKen Hughes <khughes@pacific.edu>2005-11-09 03:38:56 +0300
commit564b62901346ba0f40032616c51ac7da1c703a54 (patch)
tree04d18cc69a3dfdad56d63af5ac4801ec1764c4e7 /source/blender/python/api2_2x/NMesh.c
parent960a8724317f41beb9cb21bf027d422ceb4355c2 (diff)
-- When storing a mesh, allow TFaces without defined UV coordinates to use
some default values instead of throwing an exception. Also use only the first four UV coordinates supplied in the list.
Diffstat (limited to 'source/blender/python/api2_2x/NMesh.c')
-rw-r--r--source/blender/python/api2_2x/NMesh.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index 79e57aa60d0..e842b01eb82 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -2568,14 +2568,25 @@ static int assignFaceUV( TFace * tf, BPy_NMFace * nmface )
{
PyObject *fuv, *tmp;
int i;
+ int len;
fuv = nmface->uv;
+ /* if no UV info, allows things to proceed as normal */
if( PySequence_Length( fuv ) == 0 ) {
- PyErr_SetString ( PyExc_RuntimeError, "uv list is empty" );
- return 0;
+ tf->uv[0][0] = 0.0f; tf->uv[0][1] = 1.0f;
+ tf->uv[1][0] = 0.0f; tf->uv[1][1] = 0.0f;
+ tf->uv[2][0] = 1.0f; tf->uv[2][1] = 0.0f;
+ tf->uv[3][1] = 1.0f; tf->uv[3][1] = 1.0f;
+ return 1;
}
+
+ /* if there are too many uv coordinates, only take the first 4 */
+ len = PySequence_Length( fuv );
+ if( len > 4 )
+ len = 4;
+
/* fuv = [(u_1, v_1), ... (u_n, v_n)] */
- for( i = 0; i < PySequence_Length( fuv ); i++ ) {
+ for( i = 0; i < len; i++ ) {
tmp = PyList_GetItem( fuv, i ); /* stolen reference ! */
if( !PyArg_ParseTuple
( tmp, "ff", &( tf->uv[i][0] ), &( tf->uv[i][1] ) ) ) {