From 0f1f429cc1741900df6cf76463435dbed92ebcdc Mon Sep 17 00:00:00 2001 From: rhhong Date: Tue, 26 Oct 2021 12:28:47 -0700 Subject: [PATCH] CR feedback. Use one color instead of a color array. Signed-off-by: rhhong Signed-off-by: Gene Walters --- .../Code/Source/AtomActorDebugDraw.cpp | 43 ++++++------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp index 836e2c8822..1325455cd9 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp @@ -259,8 +259,6 @@ namespace AZ::Render m_auxVertices.clear(); m_auxVertices.reserve(numTriangles * 2); - m_auxColors.clear(); - m_auxColors.reserve(m_auxVertices.size()); for (uint32 triangleIndex = 0; triangleIndex < numTriangles; ++triangleIndex) { @@ -279,17 +277,15 @@ namespace AZ::Render const AZ::Vector3 normalPos = (posA + posB + posC) * (1.0f / 3.0f); m_auxVertices.emplace_back(normalPos); - m_auxColors.emplace_back(colorFaceNormals); m_auxVertices.emplace_back(normalPos + (normalDir * faceNormalsScale)); - m_auxColors.emplace_back(colorFaceNormals); } } RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); lineArgs.m_vertCount = static_cast(m_auxVertices.size()); - lineArgs.m_colors = m_auxColors.data(); - lineArgs.m_colorCount = static_cast(m_auxColors.size()); + lineArgs.m_colors = &colorFaceNormals; + lineArgs.m_colorCount = 1; lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; auxGeom->DrawLines(lineArgs); } @@ -306,8 +302,6 @@ namespace AZ::Render m_auxVertices.clear(); m_auxVertices.reserve(numVertices * 2); - m_auxColors.clear(); - m_auxColors.reserve(m_auxVertices.size()); for (uint32 j = 0; j < numVertices; ++j) { @@ -316,17 +310,15 @@ namespace AZ::Render const AZ::Vector3 normal = worldTM.TransformVector(normals[vertexIndex]).GetNormalizedSafe() * vertexNormalsScale; m_auxVertices.emplace_back(position); - m_auxColors.emplace_back(colorFaceNormals); m_auxVertices.emplace_back(position + normal); - m_auxColors.emplace_back(colorFaceNormals); } } RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); lineArgs.m_vertCount = static_cast(m_auxVertices.size()); - lineArgs.m_colors = m_auxColors.data(); - lineArgs.m_colorCount = static_cast(m_auxColors.size()); + lineArgs.m_colors = &colorVertexNormals; + lineArgs.m_colorCount = 1; lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; auxGeom->DrawLines(lineArgs); } @@ -417,7 +409,6 @@ namespace AZ::Render auxGeom->DrawLines(lineArgs); } - // Render wireframe mesh void AtomActorDebugDraw::RenderWireframe(EMotionFX::Mesh* mesh, const AZ::Transform& worldTM) { // Check if the mesh is valid and skip the node in case it's not @@ -436,7 +427,7 @@ namespace AZ::Render const float scale = 0.01f; - AZ::Vector3* normals = (AZ::Vector3*)mesh->FindVertexData(EMotionFX::Mesh::ATTRIB_NORMALS); + const AZ::Vector3* normals = (AZ::Vector3*)mesh->FindVertexData(EMotionFX::Mesh::ATTRIB_NORMALS); const AZ::Color vertexColor = AZ::Color(0.8f, 0.24f, 0.88f, 1.0f); const size_t numSubMeshes = mesh->GetNumSubMeshes(); @@ -449,8 +440,6 @@ namespace AZ::Render m_auxVertices.clear(); m_auxVertices.reserve(numTriangles * 6); - m_auxColors.clear(); - m_auxColors.reserve(m_auxVertices.size()); for (uint32 triangleIndex = 0; triangleIndex < numTriangles; ++triangleIndex) { @@ -464,28 +453,22 @@ namespace AZ::Render const AZ::Vector3 posC = m_worldSpacePositions[indexC] + normals[indexC] * scale; m_auxVertices.emplace_back(posA); - m_auxColors.emplace_back(vertexColor); m_auxVertices.emplace_back(posB); - m_auxColors.emplace_back(vertexColor); m_auxVertices.emplace_back(posB); - m_auxColors.emplace_back(vertexColor); m_auxVertices.emplace_back(posC); - m_auxColors.emplace_back(vertexColor); m_auxVertices.emplace_back(posC); - m_auxColors.emplace_back(vertexColor); m_auxVertices.emplace_back(posA); - m_auxColors.emplace_back(vertexColor); } - } - RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; - lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); - lineArgs.m_colors = m_auxColors.data(); - lineArgs.m_colorCount = static_cast(m_auxColors.size()); - lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; - auxGeom->DrawLines(lineArgs); + RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; + lineArgs.m_verts = m_auxVertices.data(); + lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_colors = &vertexColor; + lineArgs.m_colorCount = 1; + lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; + auxGeom->DrawLines(lineArgs); + } } } // namespace AZ::Render