Merge pull request #4397 from youkeyao/issue_3191
update the calculation and orthogonalization for bitangentpull/4399/head^2
commit
2c33ed1087
|
@ -191,9 +191,9 @@ bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) {
|
||||||
tangent.x = (w.x * sy - v.x * ty) * dirCorrection;
|
tangent.x = (w.x * sy - v.x * ty) * dirCorrection;
|
||||||
tangent.y = (w.y * sy - v.y * ty) * dirCorrection;
|
tangent.y = (w.y * sy - v.y * ty) * dirCorrection;
|
||||||
tangent.z = (w.z * sy - v.z * ty) * dirCorrection;
|
tangent.z = (w.z * sy - v.z * ty) * dirCorrection;
|
||||||
bitangent.x = (w.x * sx - v.x * tx) * dirCorrection;
|
bitangent.x = (- w.x * sx + v.x * tx) * dirCorrection;
|
||||||
bitangent.y = (w.y * sx - v.y * tx) * dirCorrection;
|
bitangent.y = (- w.y * sx + v.y * tx) * dirCorrection;
|
||||||
bitangent.z = (w.z * sx - v.z * tx) * dirCorrection;
|
bitangent.z = (- w.z * sx + v.z * tx) * dirCorrection;
|
||||||
|
|
||||||
// store for every vertex of that face
|
// store for every vertex of that face
|
||||||
for (unsigned int b = 0; b < face.mNumIndices; ++b) {
|
for (unsigned int b = 0; b < face.mNumIndices; ++b) {
|
||||||
|
@ -201,7 +201,7 @@ bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) {
|
||||||
|
|
||||||
// project tangent and bitangent into the plane formed by the vertex' normal
|
// project tangent and bitangent into the plane formed by the vertex' normal
|
||||||
aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]);
|
aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]);
|
||||||
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]);
|
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]) - localTangent * (bitangent * localTangent);
|
||||||
localTangent.NormalizeSafe();
|
localTangent.NormalizeSafe();
|
||||||
localBitangent.NormalizeSafe();
|
localBitangent.NormalizeSafe();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue