Преглед изворни кода

Fixing tangent frame generation so it properly accumulates tangents/normals

BearishSun пре 9 година
родитељ
комит
7df08fef41
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      Source/BansheeCore/Source/BsMeshUtility.cpp

+ 5 - 2
Source/BansheeCore/Source/BsMeshUtility.cpp

@@ -750,6 +750,7 @@ namespace BansheeEngine
 		{
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
+			normals[i] = Vector3::ZERO;
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 				UINT32 faceIdx = faces.faces[j];
@@ -809,8 +810,7 @@ namespace BansheeEngine
 				faceBitangents[i].normalize();
 			}
 
-			// Note: Potentially don't normalize here in order to weigh the normals
-			// by triangle size
+			// Note: Potentially don't normalize here in order to weight the normals by triangle size
 		}
 
 		VertexConnectivity connectivity(indices, numVertices, numFaces, indexSize);
@@ -818,6 +818,9 @@ namespace BansheeEngine
 		{
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
+			tangents[i] = Vector3::ZERO;
+			bitangents[i] = Vector3::ZERO;
+
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 				UINT32 faceIdx = faces.faces[j];