null reference fix for mesh with isolated vertices

http://forum.alternativaplatform.com/index.php?showtopic=4478&hl=
This commit is contained in:
makc
2013-01-25 18:23:31 +01:00
parent c8830481cb
commit 88f998a517

View File

@@ -243,6 +243,7 @@ package alternativa.engine3d.resources {
var normalsBufferStride:uint = normalsStream.attributes.length*4;
for (i = 0; i < _numVertices; i++) {
normal = normals[i];
if (normal == null) continue;
normal.normalize();
normalsBuffer.position = i*normalsBufferStride + normalsOffset;
normalsBuffer.writeFloat(normal.x);
@@ -254,7 +255,7 @@ package alternativa.engine3d.resources {
var resultByteArray:ByteArray = new ByteArray();
resultByteArray.endian = Endian.LITTLE_ENDIAN;
for (i = 0; i < _numVertices; i++) {
normal = normals[i];
normal = normals[i] || new Vector3D(0,0,1);
normal.normalize();
resultByteArray.writeBytes(positionsData, i*stride, stride);
resultByteArray.writeFloat(normal.x);