mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 01:49:07 -07:00
Merge pull request #53 from makc/patch-1
null reference fix for mesh with isolated vertices
This commit is contained in:
@@ -243,6 +243,7 @@ package alternativa.engine3d.resources {
|
|||||||
var normalsBufferStride:uint = normalsStream.attributes.length*4;
|
var normalsBufferStride:uint = normalsStream.attributes.length*4;
|
||||||
for (i = 0; i < _numVertices; i++) {
|
for (i = 0; i < _numVertices; i++) {
|
||||||
normal = normals[i];
|
normal = normals[i];
|
||||||
|
if (normal == null) continue;
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
normalsBuffer.position = i*normalsBufferStride + normalsOffset;
|
normalsBuffer.position = i*normalsBufferStride + normalsOffset;
|
||||||
normalsBuffer.writeFloat(normal.x);
|
normalsBuffer.writeFloat(normal.x);
|
||||||
@@ -254,7 +255,7 @@ package alternativa.engine3d.resources {
|
|||||||
var resultByteArray:ByteArray = new ByteArray();
|
var resultByteArray:ByteArray = new ByteArray();
|
||||||
resultByteArray.endian = Endian.LITTLE_ENDIAN;
|
resultByteArray.endian = Endian.LITTLE_ENDIAN;
|
||||||
for (i = 0; i < _numVertices; i++) {
|
for (i = 0; i < _numVertices; i++) {
|
||||||
normal = normals[i];
|
normal = normals[i] || new Vector3D(0,0,1);
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
resultByteArray.writeBytes(positionsData, i*stride, stride);
|
resultByteArray.writeBytes(positionsData, i*stride, stride);
|
||||||
resultByteArray.writeFloat(normal.x);
|
resultByteArray.writeFloat(normal.x);
|
||||||
|
|||||||
Reference in New Issue
Block a user