PR addressing. Removed RTTI from HeightMaterialPoint since it's just a struct of data with no intention being a part of class hierarchy

Signed-off-by: Sergey Pereslavtsev <pereslav@amazon.com>
monroegm-disable-blank-issue-2
Sergey Pereslavtsev 4 years ago
parent c31e3c0208
commit 56c6f81627

@ -35,16 +35,15 @@ namespace Physics
{
}
virtual ~HeightMaterialPoint() = default;
~HeightMaterialPoint() = default;
static void Reflect(AZ::ReflectContext* context);
AZ_RTTI(HeightMaterialPoint, "{DF167ED4-24E6-4F7B-8AB7-42622F7DBAD3}");
AZ_TYPE_INFO(HeightMaterialPoint, "{DF167ED4-24E6-4F7B-8AB7-42622F7DBAD3}");
float m_height{ 0.0f }; //!< Holds the height of this point in the heightfield relative to the heightfield entity location.
QuadMeshType m_quadMeshType{ QuadMeshType::SubdivideUpperLeftToBottomRight }; //!< By default, create two triangles like this |\|, where this point is in the upper left corner.
uint8_t m_materialIndex{ 0 }; //!< The surface material index for the upper left corner of this quad.
uint16_t m_padding{ 0 }; //!< available for future use.
};
//! An interface to provide heightfield values.

@ -71,7 +71,6 @@ namespace PhysX
const int32_t row, const int32_t col,
const int32_t numRows, const int32_t numCols)
{
uint8_t materialIndex0 = 0;
uint8_t materialIndex1 = 0;
@ -81,9 +80,11 @@ namespace PhysX
// In PhysX, the material indices refer to the quad down and to the right of the sample.
// If we're in the last row or last column, there aren't any quads down or to the right,
// so just clear these out.
if (!lastRowIndex && !lastColumnIndex)
if (lastRowIndex || lastColumnIndex)
{
return { materialIndex0, materialIndex1 };
}
auto GetIndex = [numCols](int32_t row, int32_t col)
{
return (row * numCols) + col;
@ -123,7 +124,7 @@ namespace PhysX
AZ_Assert(false, "Unhandled case in GetPhysXMaterialIndicesFromHeightfieldSamples");
break;
}
}
return { materialIndex0, materialIndex1 };
}

@ -139,9 +139,9 @@ namespace PhysXEditorTests
// Create an asset out of our Script Event
Physics::MaterialLibraryAsset* matLibAsset = aznew Physics::MaterialLibraryAsset;
{
AZStd::vector<Physics::MaterialId> matIds = GetMaterialList();
const AZStd::vector<Physics::MaterialId> matIds = GetMaterialList();
for (Physics::MaterialId matId : matIds)
for (const Physics::MaterialId& matId : matIds)
{
Physics::MaterialFromAssetConfiguration matConfig;
matConfig.m_id = matId;
@ -336,7 +336,7 @@ namespace PhysXEditorTests
// PhysX Heightfield cooking doesn't map 1-1 sample material indices to triangle material indices
// Hence hardcoding the expected material indices in the test
const int physicsMaterialsValidationDataIndex[] = {0, 2, 1, 1};
const AZStd::array<int, 4> physicsMaterialsValidationDataIndex = {0, 2, 1, 1};
for (int sampleRow = 0; sampleRow < numRows; ++sampleRow)
{
@ -364,12 +364,15 @@ namespace PhysXEditorTests
Physics::Material* mat2 = GetMaterialFromRaycast(rayX + secondRayOffset, rayY + secondRayOffset);
EXPECT_NE(mat2, nullptr);
if (mat1)
{
AZStd::string expectedMaterialName = physicsSurfaceTypes[physicsMaterialsValidationDataIndex[sampleRow * 2 + sampleColumn]];
EXPECT_EQ(mat1->GetSurfaceTypeName(), expectedMaterialName);
}
}
}
}
}
} // namespace PhysXEditorTests

Loading…
Cancel
Save