Utility/SubMesh: Allow tangent generation with 3D texcoords

This commit is contained in:
SirLynix 2023-12-04 09:46:31 +01:00
parent c06898fcde
commit 0c29bce3d8
1 changed files with 14 additions and 0 deletions

View File

@ -61,6 +61,13 @@ namespace Nz
SparsePtr<Vector3f> positions = mapper.GetComponentPtr<Vector3f>(VertexComponent::Position);
SparsePtr<Vector3f> tangents = mapper.GetComponentPtr<Vector3f>(VertexComponent::Tangent);
SparsePtr<Vector2f> texCoords = mapper.GetComponentPtr<Vector2f>(VertexComponent::TexCoord);
if (!texCoords)
{
// 3D coords are often used for slice indexing, we can get a Vector2 by keeping the stride
SparsePtr<Vector3f> texCoords3D = mapper.GetComponentPtr<Vector3f>(VertexComponent::TexCoord);
texCoords = SparsePtr<Vector2f>(texCoords3D.GetPtr(), texCoords3D.GetStride());
}
if (!normals || !positions || !tangents || !texCoords)
return;
@ -118,6 +125,13 @@ namespace Nz
SparsePtr<Vector3f> positions = mapper.GetComponentPtr<Vector3f>(VertexComponent::Position);
SparsePtr<Vector3f> tangents = mapper.GetComponentPtr<Vector3f>(VertexComponent::Tangent);
SparsePtr<Vector2f> texCoords = mapper.GetComponentPtr<Vector2f>(VertexComponent::TexCoord);
if (!texCoords)
{
// 3D coords are often used for slice indexing, we can get a Vector2 by keeping the stride
SparsePtr<Vector3f> texCoords3D = mapper.GetComponentPtr<Vector3f>(VertexComponent::TexCoord);
texCoords = SparsePtr<Vector2f>(texCoords3D.GetPtr(), texCoords3D.GetStride());
}
if (!normals || !positions || !tangents || !texCoords)
return;