fix bug with wrong number of tube manipulators returned

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-07-15 13:25:00 +01:00
parent 5c177ef48a
commit 4b9c2cceb4
4 changed files with 163 additions and 33 deletions
@@ -268,28 +268,6 @@ namespace LmbrCentral
ContainerChanged();
}
AZStd::vector<EditorTubeShapeComponentMode::TubeManipulatorState> EditorTubeShapeComponentMode::GenerateTubeManipulatorStates(
const AZ::Spline& spline)
{
const AZ::u64 startVertex = spline.GetAddressByFraction(0.0f).m_segmentIndex;
const AZ::u64 endVertex = startVertex + spline.GetSegmentCount() + (spline.IsClosed() ? 0 : 1);
AZStd::vector<TubeManipulatorState> splineAddresses;
for (AZ::u64 vertIndex = startVertex; vertIndex < endVertex; ++vertIndex)
{
if (vertIndex + 1 == endVertex)
{
splineAddresses.push_back({ AZ::SplineAddress(vertIndex - 1, 1.0f), vertIndex });
}
else
{
splineAddresses.push_back({ AZ::SplineAddress(vertIndex), vertIndex });
}
}
return splineAddresses;
}
void EditorTubeShapeComponentMode::RefreshManipulatorsLocal(const AZ::EntityId entityId)
{
AZ::SplinePtr spline;
@@ -318,4 +296,37 @@ namespace LmbrCentral
m_radiusManipulators[manipulatorIndex]->SetBoundsDirty();
}
}
AZStd::vector<EditorTubeShapeComponentMode::TubeManipulatorState> GenerateTubeManipulatorStates(const AZ::Spline& spline)
{
if (spline.GetVertexCount() == 0)
{
return {};
}
const auto segmentCount = spline.GetSegmentCount();
if (segmentCount == 0)
{
return { { AZ::SplineAddress(0), 0 } };
}
const AZ::u64 startVertex = spline.GetAddressByFraction(0.0f).m_segmentIndex;
const AZ::u64 endVertex = startVertex + segmentCount + (spline.IsClosed() ? 0 : 1);
AZStd::vector<EditorTubeShapeComponentMode::TubeManipulatorState> splineAddresses;
for (AZ::u64 vertIndex = startVertex; vertIndex < endVertex; ++vertIndex)
{
if (vertIndex + 1 == endVertex)
{
AZ_Assert(vertIndex > 0, "vertexIndex is 0 and not safe to subtract from")
splineAddresses.push_back({ AZ::SplineAddress(vertIndex - 1, 1.0f), vertIndex });
}
else
{
splineAddresses.push_back({ AZ::SplineAddress(vertIndex), vertIndex });
}
}
return splineAddresses;
}
} // namespace LmbrCentral