Merge pull request #7248 from aws-lumberyard-dev/TerrainMaterialsFix

Fixed crash and asserts when heightfield is used without Terrain World
monroegm-disable-blank-issue-2
SergeyAMZN 4 years ago committed by GitHub
commit c6a0d76843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -687,14 +687,19 @@ namespace PhysX
[[maybe_unused]] const AZ::Vector3& colliderScale, [[maybe_unused]] const AZ::Vector3& colliderScale,
[[maybe_unused]] const bool forceUniformScaling) const [[maybe_unused]] const bool forceUniformScaling) const
{ {
auto heights = heightfieldShapeConfig.GetSamples();
if (heights.empty())
{
return;
}
const int numColumns = heightfieldShapeConfig.GetNumColumns(); const int numColumns = heightfieldShapeConfig.GetNumColumns();
const int numRows = heightfieldShapeConfig.GetNumRows(); const int numRows = heightfieldShapeConfig.GetNumRows();
const float minXBounds = -(numColumns * heightfieldShapeConfig.GetGridResolution().GetX()) / 2.0f; const float minXBounds = -(numColumns * heightfieldShapeConfig.GetGridResolution().GetX()) / 2.0f;
const float minYBounds = -(numRows * heightfieldShapeConfig.GetGridResolution().GetY()) / 2.0f; const float minYBounds = -(numRows * heightfieldShapeConfig.GetGridResolution().GetY()) / 2.0f;
auto heights = heightfieldShapeConfig.GetSamples();
for (int xIndex = 0; xIndex < numColumns - 1; xIndex++) for (int xIndex = 0; xIndex < numColumns - 1; xIndex++)
{ {
for (int yIndex = 0; yIndex < numRows - 1; yIndex++) for (int yIndex = 0; yIndex < numRows - 1; yIndex++)

@ -211,7 +211,12 @@ namespace PhysX
{ {
ClearHeightfield(); ClearHeightfield();
InitHeightfieldShapeConfiguration(); InitHeightfieldShapeConfiguration();
InitStaticRigidBody();
if (!m_shapeConfig->GetSamples().empty())
{
InitStaticRigidBody();
}
Physics::ColliderComponentEventBus::Event(GetEntityId(), &Physics::ColliderComponentEvents::OnColliderChanged); Physics::ColliderComponentEventBus::Event(GetEntityId(), &Physics::ColliderComponentEvents::OnColliderChanged);
} }

@ -150,7 +150,13 @@ namespace PhysX
{ {
ClearHeightfield(); ClearHeightfield();
InitHeightfieldShapeConfiguration(); InitHeightfieldShapeConfiguration();
InitStaticRigidBody();
Physics::HeightfieldShapeConfiguration& configuration = static_cast<Physics::HeightfieldShapeConfiguration&>(*m_shapeConfig.second);
if (!configuration.GetSamples().empty())
{
InitStaticRigidBody();
}
Physics::ColliderComponentEventBus::Event(GetEntityId(), &Physics::ColliderComponentEvents::OnColliderChanged); Physics::ColliderComponentEventBus::Event(GetEntityId(), &Physics::ColliderComponentEvents::OnColliderChanged);
} }

Loading…
Cancel
Save