Integrating up through commit 90f050496
This commit is contained in:
@@ -30,6 +30,61 @@ namespace AZ
|
||||
return static_cast<unsigned int>(m_positions.size()-1);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddTangentAndBitangent(const Vector4& tangent, const Vector3& bitangent)
|
||||
{
|
||||
m_tangents.push_back(tangent);
|
||||
m_bitangents.push_back(bitangent);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddUV(const Vector2& uv, AZ::u8 uvSetIndex)
|
||||
{
|
||||
if (uvSetIndex >= MaxNumUVSets)
|
||||
{
|
||||
AZ_ErrorOnce("SceneGraphData", false, "uvSetIndex %zu is greater or equal than the maximum uv sets %zu.", uvSetIndex, MaxNumUVSets);
|
||||
return;
|
||||
}
|
||||
m_uvs[uvSetIndex].push_back(uv);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddColor(const SceneAPI::DataTypes::Color& color, AZ::u8 colorSetIndex)
|
||||
{
|
||||
if (colorSetIndex >= MaxNumColorSets)
|
||||
{
|
||||
AZ_ErrorOnce("SceneGraphData", false, "colorSetIndex %zu is greater or equal than the maximum color sets %zu.", colorSetIndex, MaxNumColorSets);
|
||||
return;
|
||||
}
|
||||
m_colors[colorSetIndex].push_back(color);
|
||||
}
|
||||
|
||||
void BlendShapeData::ReserveData(
|
||||
unsigned int numVertices, bool reserveTangents, const AZStd::bitset<MaxNumUVSets>& uvSetUsedFlags,
|
||||
const AZStd::bitset<MaxNumColorSets>& colorSetUsedFlags)
|
||||
{
|
||||
m_positions.reserve(numVertices);
|
||||
m_normals.reserve(numVertices);
|
||||
if (reserveTangents)
|
||||
{
|
||||
m_tangents.reserve(numVertices);
|
||||
m_bitangents.reserve(numVertices);
|
||||
}
|
||||
|
||||
for (AZ::u8 uvSetIndex = 0; uvSetIndex < MaxNumUVSets; ++uvSetIndex)
|
||||
{
|
||||
if (uvSetUsedFlags[uvSetIndex])
|
||||
{
|
||||
m_uvs[uvSetIndex].reserve(numVertices);
|
||||
}
|
||||
}
|
||||
|
||||
for (AZ::u8 colorSetIndex = 0; colorSetIndex < MaxNumColorSets; ++colorSetIndex)
|
||||
{
|
||||
if (colorSetUsedFlags[colorSetIndex])
|
||||
{
|
||||
m_colors[colorSetIndex].reserve(numVertices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlendShapeData::AddFace(const Face& face)
|
||||
{
|
||||
m_faces.push_back(face);
|
||||
@@ -47,7 +102,7 @@ namespace AZ
|
||||
int BlendShapeData::GetControlPointIndex(int vertexIndex) const
|
||||
{
|
||||
auto iter = m_vertexIndexToControlPointIndexMap.find(vertexIndex);
|
||||
AZ_Assert(iter != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist", vertexIndex);
|
||||
AZ_Assert(iter != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist.", vertexIndex);
|
||||
// Note: AZStd::unordered_map's operator [] doesn't have const version...
|
||||
return iter->second;
|
||||
}
|
||||
@@ -92,6 +147,45 @@ namespace AZ
|
||||
return m_normals[index];
|
||||
}
|
||||
|
||||
const Vector2& BlendShapeData::GetUV(unsigned int vertexIndex, unsigned int uvSetIndex) const
|
||||
{
|
||||
AZ_Assert(uvSetIndex < MaxNumUVSets, "uvSet index out of range");
|
||||
AZ_Assert(vertexIndex < m_uvs[uvSetIndex].size(), "uvSet index out of range");
|
||||
return m_uvs[uvSetIndex][vertexIndex];
|
||||
}
|
||||
|
||||
AZStd::vector<Vector4>& BlendShapeData::GetTangents()
|
||||
{
|
||||
return m_tangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector4>& BlendShapeData::GetTangents() const
|
||||
{
|
||||
return m_tangents;
|
||||
}
|
||||
|
||||
AZStd::vector<Vector3>& BlendShapeData::GetBitangents()
|
||||
{
|
||||
return m_bitangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector3>& BlendShapeData::GetBitangents() const
|
||||
{
|
||||
return m_bitangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector2>& BlendShapeData::GetUVs(AZ::u8 uvSetIndex) const
|
||||
{
|
||||
AZ_Assert(uvSetIndex < MaxNumUVSets, "uvSet index out of range");
|
||||
return m_uvs[uvSetIndex];
|
||||
}
|
||||
|
||||
const AZStd::vector<SceneAPI::DataTypes::Color>& BlendShapeData::GetColors(AZ::u8 colorSetIndex) const
|
||||
{
|
||||
AZ_Assert(colorSetIndex < MaxNumColorSets, "colorSet index out of range");
|
||||
return m_colors[colorSetIndex];
|
||||
}
|
||||
|
||||
unsigned int BlendShapeData::GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const
|
||||
{
|
||||
AZ_Assert(face < m_faces.size(), "GetFaceVertexPositionIndex face index not in range");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -30,8 +31,19 @@ namespace AZ
|
||||
public:
|
||||
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
|
||||
|
||||
// Maximum number of color sets matches limitation set in assImp (AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||
static constexpr AZ::u8 MaxNumColorSets = 8;
|
||||
// Maximum number of uv sets matches limitation set in assImp (AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||
static constexpr AZ::u8 MaxNumUVSets = 8;
|
||||
|
||||
SCENE_DATA_API ~BlendShapeData() override;
|
||||
SCENE_DATA_API virtual unsigned int AddVertex(const Vector3& position, const Vector3& normal);
|
||||
SCENE_DATA_API void AddTangentAndBitangent(const Vector4& tangent, const Vector3& bitangent);
|
||||
SCENE_DATA_API void AddUV(const Vector2& uv, AZ::u8 uvSetIndex);
|
||||
SCENE_DATA_API void AddColor(const SceneAPI::DataTypes::Color& color, AZ::u8 colorSetIndex);
|
||||
SCENE_DATA_API void ReserveData(
|
||||
unsigned int numVertices, bool reserveTangents, const AZStd::bitset<MaxNumUVSets>& uvSetUsedFlags,
|
||||
const AZStd::bitset<MaxNumColorSets>& colorSetUsedFlags);
|
||||
|
||||
//assume consistent winding - no stripping or fanning expected (3 index per face)
|
||||
SCENE_DATA_API virtual void AddFace(const Face& face);
|
||||
@@ -48,6 +60,14 @@ namespace AZ
|
||||
|
||||
SCENE_DATA_API const Vector3& GetPosition(unsigned int index) const override;
|
||||
SCENE_DATA_API const Vector3& GetNormal(unsigned int index) const override;
|
||||
SCENE_DATA_API const Vector2& GetUV(unsigned int vertexIndex, unsigned int uvSetIndex) const;
|
||||
|
||||
SCENE_DATA_API AZStd::vector<Vector4>& GetTangents();
|
||||
SCENE_DATA_API const AZStd::vector<Vector4>& GetTangents() const;
|
||||
SCENE_DATA_API AZStd::vector<Vector3>& GetBitangents();
|
||||
SCENE_DATA_API const AZStd::vector<Vector3>& GetBitangents() const;
|
||||
SCENE_DATA_API const AZStd::vector<Vector2>& GetUVs(AZ::u8 uvSetIndex) const;
|
||||
SCENE_DATA_API const AZStd::vector<SceneAPI::DataTypes::Color>& GetColors(AZ::u8 colorSetIndex) const;
|
||||
|
||||
SCENE_DATA_API unsigned int GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const override;
|
||||
|
||||
@@ -56,6 +76,11 @@ namespace AZ
|
||||
protected:
|
||||
AZStd::vector<Vector3> m_positions;
|
||||
AZStd::vector<Vector3> m_normals;
|
||||
AZStd::vector<Vector4> m_tangents;
|
||||
AZStd::vector<Vector3> m_bitangents;
|
||||
AZStd::vector<AZ::Vector2> m_uvs[MaxNumUVSets];
|
||||
AZStd::vector<SceneAPI::DataTypes::Color> m_colors[MaxNumColorSets];
|
||||
|
||||
AZStd::vector<Face> m_faces;
|
||||
|
||||
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
|
||||
|
||||
Reference in New Issue
Block a user