+ int v = i - c;
+ double w = weights[v];
+ //normals[index].Add(normals[index], planeNormal);
+ normals[index].x += planeNormal.x * w;
+ normals[index].y += planeNormal.y * w;
+ normals[index].z += planeNormal.z * w;
+ weightSum[index] += w;
+ //numShared[index] ++;
+
+ if(tangents)
+ {
+ uint ix0 = index;
+ uint prev = v ? i - 1 : c + nIndex-1;
+ uint next = v < nIndex-1 ? i + 1 : c;
+ uint ix1 = i32bit ? indices32[next] : indices16[next];
+ uint ix2 = i32bit ? indices32[prev] : indices16[prev];
+ Vector3Df * p0 = &vertices [ix0], * p1 = &vertices [ix1], * p2 = &vertices[ix2];
+ Pointf * t0 = &texCoords[ix0], * t1 = &texCoords[ix1], * t2 = &texCoords[ix2];
+ Vector3D v01 { p1->x - p0->x, p1->y - p0->y, p1->z - p0->z };
+ Vector3D v02 { p2->x - p0->x, p2->y - p0->y, p2->z - p0->z };
+ Pointf t01 { t1->x - t0->x, t1->y - t0->y };
+ Pointf t02 { t2->x - t0->x, t2->y - t0->y };
+ //if(Abs(t01.x) > 0.99) t01.x = 0;
+ //if(Abs(t02.x) > 0.99) t02.x = 0;
+
+ double f = w / (t01.x * t02.y - t02.x * t01.y);
+ Vector3Df * tan1 = &tangents[index*2+0];
+ Vector3Df * tan2 = &tangents[index*2+1];
+
+ tan1->x += f * (v01.x * t02.y - v02.x * t01.y);
+ tan1->y += f * (v01.y * t02.y - v02.y * t01.y);
+ tan1->z += f * (v01.z * t02.y - v02.z * t01.y);
+
+ tan2->x += f * (v02.x * t01.x - v01.x * t02.x);
+ tan2->y += f * (v02.y * t01.x - v01.y * t02.x);
+ tan2->z += f * (v02.z * t01.x - v01.z * t02.x);
+ }