some tidying up
This commit is contained in:
@@ -58,6 +58,8 @@ namespace AZ
|
||||
}
|
||||
|
||||
{
|
||||
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
|
||||
// we need to pick one number to use for load/store operations.
|
||||
float scale = transformInstance->GetUniformScale();
|
||||
|
||||
JSR::ResultCode loadResult =
|
||||
@@ -120,6 +122,8 @@ namespace AZ
|
||||
{
|
||||
AZ::ScopedContextPath subPathName(context, ScaleTag);
|
||||
|
||||
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
|
||||
// we need to pick one number to use for load/store operations.
|
||||
float scale = transformInstance->GetUniformScale();
|
||||
float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetUniformScale() : 0.0f;
|
||||
|
||||
|
||||
@@ -433,18 +433,21 @@ namespace LmbrCentral
|
||||
const float height = polygonPrism.GetHeight();
|
||||
const AZ::Vector3& nonUniformScale = polygonPrism.GetNonUniformScale();
|
||||
|
||||
AZ::Transform worldFromLocalUniformScale = worldFromLocal;
|
||||
worldFromLocalUniformScale.SetUniformScale(worldFromLocalUniformScale.GetUniformScale());
|
||||
|
||||
AZ::Aabb aabb = AZ::Aabb::CreateNull();
|
||||
// check base of prism
|
||||
for (const AZ::Vector2& vertex : vertexContainer.GetVertices())
|
||||
{
|
||||
aabb.AddPoint(worldFromLocal.TransformPoint(nonUniformScale * AZ::Vector3(vertex.GetX(), vertex.GetY(), 0.0f)));
|
||||
aabb.AddPoint(worldFromLocalUniformScale.TransformPoint(nonUniformScale * AZ::Vector3(vertex.GetX(), vertex.GetY(), 0.0f)));
|
||||
}
|
||||
|
||||
// check top of prism
|
||||
// set aabb to be height of prism - ensure entire polygon prism shape is enclosed in aabb
|
||||
for (const AZ::Vector2& vertex : vertexContainer.GetVertices())
|
||||
{
|
||||
aabb.AddPoint(worldFromLocal.TransformPoint(nonUniformScale * AZ::Vector3(vertex.GetX(), vertex.GetY(), height)));
|
||||
aabb.AddPoint(worldFromLocalUniformScale.TransformPoint(nonUniformScale * AZ::Vector3(vertex.GetX(), vertex.GetY(), height)));
|
||||
}
|
||||
|
||||
return aabb;
|
||||
@@ -460,10 +463,13 @@ namespace LmbrCentral
|
||||
const AZStd::vector<AZ::Vector2>& vertices = polygonPrism.m_vertexContainer.GetVertices();
|
||||
const size_t vertexCount = vertices.size();
|
||||
|
||||
AZ::Transform worldFromLocalWithUniformScale = worldFromLocal;
|
||||
worldFromLocalWithUniformScale.SetUniformScale(worldFromLocalWithUniformScale.GetUniformScale());
|
||||
|
||||
// transform point to local space
|
||||
// it's fine to invert the transform including scale here, because it won't affect whether the point is inside the prism
|
||||
const AZ::Vector3 localPoint =
|
||||
worldFromLocal.GetInverse().TransformPoint(point) / polygonPrism.GetNonUniformScale();
|
||||
worldFromLocalWithUniformScale.GetInverse().TransformPoint(point) / polygonPrism.GetNonUniformScale();
|
||||
|
||||
// ensure the point is not above or below the prism (in its local space)
|
||||
if (localPoint.GetZ() < 0.0f || localPoint.GetZ() > polygonPrism.GetHeight())
|
||||
|
||||
@@ -42,7 +42,11 @@ namespace LmbrCentral
|
||||
return;
|
||||
}
|
||||
|
||||
debugDisplay.PushMatrix(worldFromLocal);
|
||||
// only uniform scale is supported in physics so the debug visuals reflect this fact
|
||||
AZ::Transform worldFromLocalWithUniformScale = worldFromLocal;
|
||||
worldFromLocalWithUniformScale.SetUniformScale(worldFromLocalWithUniformScale.GetUniformScale());
|
||||
|
||||
debugDisplay.PushMatrix(worldFromLocalWithUniformScale);
|
||||
|
||||
drawShape(debugDisplay);
|
||||
|
||||
|
||||
@@ -216,7 +216,10 @@ namespace LmbrCentral
|
||||
return AZ::Aabb::CreateNull();
|
||||
}
|
||||
|
||||
return CalculateTubeBounds(*this, m_currentTransform);
|
||||
AZ::Transform worldFromLocalUniformScale = m_currentTransform;
|
||||
worldFromLocalUniformScale.SetUniformScale(worldFromLocalUniformScale.GetUniformScale());
|
||||
|
||||
return CalculateTubeBounds(*this, worldFromLocalUniformScale);
|
||||
}
|
||||
|
||||
void TubeShape::GetTransformAndLocalBounds(AZ::Transform& transform, AZ::Aabb& bounds)
|
||||
@@ -232,8 +235,10 @@ namespace LmbrCentral
|
||||
return false;
|
||||
}
|
||||
|
||||
const float scale = m_currentTransform.GetUniformScale();
|
||||
const AZ::Vector3 localPoint = m_currentTransform.GetInverse().TransformPoint(point);
|
||||
AZ::Transform worldFromLocalNormalized = m_currentTransform;
|
||||
const float scale = worldFromLocalNormalized.ExtractUniformScale();
|
||||
const AZ::Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
|
||||
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) / scale;
|
||||
|
||||
const auto address = m_spline->GetNearestAddressPosition(localPoint).m_splineAddress;
|
||||
const float radiusSq = powf(m_radius, 2.0f);
|
||||
@@ -245,20 +250,24 @@ namespace LmbrCentral
|
||||
|
||||
float TubeShape::DistanceSquaredFromPoint(const AZ::Vector3& point)
|
||||
{
|
||||
const float scale = m_currentTransform.GetUniformScale();
|
||||
const AZ::Transform localFromWorld = m_currentTransform.GetInverse();
|
||||
const AZ::Vector3 localPoint = localFromWorld.TransformPoint(point);
|
||||
AZ::Transform worldFromLocalNormalized = m_currentTransform;
|
||||
const float uniformScale = worldFromLocalNormalized.ExtractUniformScale();
|
||||
const AZ::Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
|
||||
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) / uniformScale;
|
||||
|
||||
const auto splineQueryResult = m_spline->GetNearestAddressPosition(localPoint);
|
||||
const float variableRadius =
|
||||
m_variableRadius.GetElementInterpolated(splineQueryResult.m_splineAddress, Lerpf);
|
||||
|
||||
return powf((sqrtf(splineQueryResult.m_distanceSq) - (m_radius + variableRadius)) * scale, 2.0f);
|
||||
return powf((sqrtf(splineQueryResult.m_distanceSq) - (m_radius + variableRadius)) * uniformScale, 2.0f);
|
||||
}
|
||||
|
||||
bool TubeShape::IntersectRay(const AZ::Vector3& src, const AZ::Vector3& dir, float& distance)
|
||||
{
|
||||
const auto splineQueryResult = IntersectSpline(m_currentTransform, src, dir, *m_spline);
|
||||
AZ::Transform transformUniformScale = m_currentTransform;
|
||||
transformUniformScale.SetUniformScale(transformUniformScale.GetUniformScale());
|
||||
|
||||
const auto splineQueryResult = IntersectSpline(transformUniformScale, src, dir, *m_spline);
|
||||
const float variableRadius = m_variableRadius.GetElementInterpolated(
|
||||
splineQueryResult.m_splineAddress, Lerpf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user