Ensure positions can be read for sources that have stride
authorNathan Letwory <nathan@letworyinteractive.com>
Thu, 19 Sep 2013 21:59:22 +0000 (21:59 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Thu, 19 Sep 2013 21:59:22 +0000 (21:59 +0000)
defined as 2 (2D coordinates).

source/blender/collada/MeshImporter.cpp

index 0c46a2bd858d636c7a8d36ca29550d8ebcf79b69..09d71f22a0d29ae40d2e54228fd09ed630f72309 100644 (file)
@@ -665,7 +665,11 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
 
                        v[0] = (*values)[i++];
                        v[1] = (*values)[i++];
-                       v[2] = (*values)[i];
+                       if(stride>=3) {
+                               v[2] = (*values)[i];
+                       } else {
+                               v[2] = 0.0f;
+                       }
 
                }
                break;
@@ -676,13 +680,18 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
 
                        v[0] = (float)(*values)[i++];
                        v[1] = (float)(*values)[i++];
-                       v[2] = (float)(*values)[i];
+                       if(stride>=3) {
+                               v[2] = (float)(*values)[i];
+                       } else {
+                               v[2] = 0.0f;
+                       }
                }
                break;
                default:
                        break;
        }
 }
+
 bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, int count)
 {
        float a[3], b[3];