Fixed tangent generation and added Vector4 type.

This commit is contained in:
2023-12-15 02:20:50 +01:00
parent b692425f83
commit 8ce77cf8bf
3 changed files with 50 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ struct MikktData
Mesh3DTraits<TMesh> traits;
Vector2Traits<typename TMesh::vector2_t> vec2Traits;
Vector3Traits<typename TMesh::vector3_t> vec3Traits;
Vector4Traits<typename TMesh::vector4_t> vec4Traits;
TMesh* mesh;
};
@@ -67,13 +68,12 @@ void mikktGetTexCoord(const SMikkTSpaceContext* context, float texcOut[], const
template<FullMesh3D TMesh>
void mikktSetTSpaceBasic(const SMikkTSpaceContext* context, const float resultTangent[], const float sign, const int face, const int vert) // NOLINT
{
// TODO: what do we do with sign? (it should be used for the direction of the bitangent)
(void) sign;
const MikktData<TMesh>& data = *static_cast<MikktData<TMesh>*>(context->m_pUserData);
typename Mesh3DTraits<TMesh>::vector3_t tangent;
data.vec3Traits.setX(tangent, resultTangent[0]);
data.vec3Traits.setY(tangent, resultTangent[1]);
data.vec3Traits.setZ(tangent, resultTangent[2]);
typename Mesh3DTraits<TMesh>::vector4_t tangent;
data.vec4Traits.setX(tangent, resultTangent[0]);
data.vec4Traits.setY(tangent, resultTangent[1]);
data.vec4Traits.setZ(tangent, resultTangent[2]);
data.vec4Traits.setW(tangent, sign);
data.traits.setTangent(*data.mesh, face, vert, tangent);
}
}