update to use uniform scale calls to Transform

main
greerdv 5 years ago
parent c2e965ea5a
commit bdf9ac31fb

@ -112,7 +112,7 @@ namespace JsonSerializationTests
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
AZ::Transform expectedTransform =
AZ::Transform::CreateFromQuaternion(AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f));
expectedTransform.SetScale(AZ::Vector3(5.5f));
expectedTransform.SetUniformScale(5.5f);
rapidjson::Document json;
json.Parse(R"({ "Rotation": [ 0.25, 0.5, 0.75, 1.0 ], "Scale": 5.5 })");
@ -128,7 +128,7 @@ namespace JsonSerializationTests
{
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
AZ::Transform expectedTransform = AZ::Transform::CreateTranslation(AZ::Vector3(2.25f, 3.5f, 4.75f));
expectedTransform.SetScale(AZ::Vector3(5.5f));
expectedTransform.SetUniformScale(5.5f);
rapidjson::Document json;
json.Parse(R"({ "Translation": [ 2.25, 3.5, 4.75 ], "Scale": 5.5 })");

@ -23,7 +23,7 @@ namespace AzToolsFramework
inline AZ::Transform TransformNormalizedScale(const AZ::Transform& transform)
{
AZ::Transform transformNormalizedScale = transform;
transformNormalizedScale.SetScale(AZ::Vector3::CreateOne());
transformNormalizedScale.SetUniformScale(1.0f);
return transformNormalizedScale;
}

@ -2963,7 +2963,7 @@ namespace AzToolsFramework
if (transformIt != transformsBefore.end())
{
AZ::Transform transformBefore = transformIt->second;
transformBefore.ExtractScale();
transformBefore.ExtractUniformScale();
AZ::Transform newWorldFromLocal = transformBefore * scaleTransform;
SetEntityWorldTransform(entityId, newWorldFromLocal);

@ -318,7 +318,7 @@ namespace AZ
{
AZ::Transform meshTransform = transformFeatureProcessor->GetTransformForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first));
AZ::Transform noScaleTransform = meshTransform;
noScaleTransform.ExtractScale();
noScaleTransform.ExtractUniformScale();
AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromTransform(noScaleTransform);
rotationMatrix = rotationMatrix.GetInverseFull().GetTranspose();

@ -231,7 +231,7 @@ namespace AZ
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the transform for an invalid handle.");
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
AZ::Transform transform = AZ::Transform::CreateFromMatrix3x4(matrix3x4);
transform.ExtractScale();
transform.ExtractUniformScale();
return transform;
}

@ -35,7 +35,7 @@ namespace AZ
// This equation is based off of the integration of a line segment against a perpendicular normal pointing at the center of the
// line segment from some distance away.
float scale = GetTransform().GetScale().GetMaxElement();
float scale = GetTransform().GetUniformScale();
float h = GetInteriorHeight() * scale;
float t2 = lightThreshold * lightThreshold;
float h2 = h * h;
@ -54,7 +54,7 @@ namespace AZ
const auto endpoints = m_shapeBus->GetCapsulePoints();
GetFeatureProcessor()->SetCapsuleLineSegment(GetLightHandle(), endpoints.m_begin, endpoints.m_end);
float scale = GetTransform().GetScale().GetMaxElement();
float scale = GetTransform().GetUniformScale();
float radius = m_shapeBus->GetRadius();
GetFeatureProcessor()->SetCapsuleRadius(GetLightHandle(), scale * radius);
}
@ -62,7 +62,7 @@ namespace AZ
float CapsuleLightDelegate::GetSurfaceArea() const
{
float scale = GetTransform().GetScale().GetMaxElement();
float scale = GetTransform().GetUniformScale();
float radius = m_shapeBus->GetRadius();
float capsArea = 4.0f * Constants::Pi * radius * radius; // both caps make a sphere
float sideArea = 2.0f * Constants::Pi * radius * GetInteriorHeight(); // cylindrical area of capsule
@ -77,7 +77,7 @@ namespace AZ
float radius = CalculateAttenuationRadius(AreaLightComponentConfig::CutoffIntensity);
// Add on the caps for the attenuation radius
float scale = GetTransform().GetScale().GetMaxElement();
float scale = GetTransform().GetUniformScale();
float height = m_shapeBus->GetHeight() * scale;
debugDisplay.SetColor(color);

@ -48,7 +48,7 @@ namespace AZ::Render
float DiskLightDelegate::GetRadius() const
{
return m_shapeBus->GetRadius() * GetTransform().GetScale().GetMaxElement();
return m_shapeBus->GetRadius() * GetTransform().GetUniformScale();
}
void DiskLightDelegate::DrawDebugDisplay(const Transform& transform, const Color& /*color*/, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const

@ -217,7 +217,7 @@ namespace AZ
GetEntityId(),
&TransformBus::Events::GetWorldTM);
transform.ExtractScale();
transform.ExtractUniformScale();
const Vector3 origin = transform.GetTranslation();
const Vector3 originOffset = origin - (transform.TransformVector(forward) * arrowOffset);
const Vector3 target = origin - (transform.TransformVector(forward) * (arrowLength + arrowOffset));

@ -73,7 +73,7 @@ namespace AZ
twiceArea += vertices.at(i).GetX() * vertices.at(j).GetY();
twiceArea -= vertices.at(i).GetY() * vertices.at(j).GetX();
}
float scale = GetTransform().GetScale().GetMaxElement();
float scale = GetTransform().GetUniformScale();
return GetAbs(twiceArea * 0.5f * scale * scale);
}

@ -50,7 +50,7 @@ namespace AZ
float SphereLightDelegate::GetRadius() const
{
return m_shapeBus->GetRadius() * GetTransform().GetScale().GetMaxElement();
return m_shapeBus->GetRadius() * GetTransform().GetUniformScale();
}
void SphereLightDelegate::DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const

@ -228,7 +228,7 @@ namespace AZ
// remove scale
Transform worldNoScale = world;
worldNoScale.ExtractScale();
worldNoScale.ExtractUniformScale();
AZ::Matrix3x4 transformMatrix = AZ::Matrix3x4::CreateFromTransform(worldNoScale);
transformMatrix.StoreToRowMajorFloat12(matrix);

@ -218,7 +218,7 @@ namespace AZ
SunPosition PhysicalSkyComponentController::GetSunTransform(const AZ::Transform& world)
{
Transform worldNoScale = world;
worldNoScale.ExtractScale();
worldNoScale.ExtractUniformScale();
AZ::Vector3 sunPositionAtom = worldNoScale.TransformVector(AZ::Vector3(0, -1, 0)); // transform Sun from default position
// Convert sun position to Y-up coordinate

@ -68,7 +68,7 @@ namespace Blast
auto transform = AZ::Transform::CreateFromQuaternionAndTranslation(
m_bodyConfiguration.m_orientation, m_bodyConfiguration.m_position);
transform.MultiplyByScale(AZ::Vector3(m_scale));
transform.MultiplyByUniformScale(m_scale);
AZ::TransformBus::Event(m_entity->GetId(), &AZ::TransformInterface::SetWorldTM, transform);

@ -202,7 +202,7 @@ namespace Blast
if (parentBody)
{
parentTransform = parentBody->GetTransform();
parentTransform.MultiplyByScale(AZ::Vector3(m_initialTransform.GetScale().GetMaxElement()));
parentTransform.MultiplyByUniformScale(m_initialTransform.GetUniformScale());
}
else
{
@ -254,7 +254,7 @@ namespace Blast
actorDesc.m_parentCenterOfMass = transform.GetTranslation();
actorDesc.m_parentLinearVelocity = AZ::Vector3::CreateZero();
actorDesc.m_bodyConfiguration = configuration;
actorDesc.m_scale = transform.GetScale().GetMaxElement();
actorDesc.m_scale = transform.GetUniformScale();
return actorDesc;
}

@ -203,7 +203,7 @@ namespace LmbrCentral
const AZ::Transform& currentTransform, const CapsuleShapeConfig& configuration,
[[maybe_unused]] const AZ::Vector3& currentNonUniformScale)
{
const float entityScale = currentTransform.GetScale().GetMaxElement();
const float entityScale = currentTransform.GetUniformScale();
m_axisVector = currentTransform.GetBasisZ().GetNormalizedSafe() * entityScale;
const float internalCylinderHeight = configuration.m_height - configuration.m_radius * 2.0f;

@ -273,7 +273,7 @@ namespace LmbrCentral
const AZ::Transform& currentTransform, const CylinderShapeConfig& configuration,
[[maybe_unused]] const AZ::Vector3& currentNonUniformScale)
{
const float entityScale = currentTransform.GetScale().GetMaxElement();
const float entityScale = currentTransform.GetUniformScale();
m_axisVector = currentTransform.GetBasisZ().GetNormalizedSafe() * entityScale;
m_baseCenterPoint = currentTransform.GetTranslation() - m_axisVector * (configuration.m_height * 0.5f);
m_axisVector = m_axisVector * configuration.m_height;

@ -167,7 +167,7 @@ namespace LmbrCentral
{
m_position = currentTransform.GetTranslation();
m_normal = currentTransform.GetBasisZ().GetNormalized();
m_radius = configuration.m_radius * currentTransform.GetScale().GetMaxElement();
m_radius = configuration.m_radius * currentTransform.GetUniformScale();
}
const DiskShapeConfig& DiskShape::GetDiskConfiguration() const

@ -174,6 +174,6 @@ namespace LmbrCentral
AZ::Vector3 EditorBoxShapeComponent::GetBoxScale()
{
return AZ::Vector3(m_boxShape.GetCurrentTransform().GetScale().GetMaxElement() * m_boxShape.GetCurrentNonUniformScale());
return AZ::Vector3(m_boxShape.GetCurrentTransform().GetUniformScale() * m_boxShape.GetCurrentNonUniformScale());
}
} // namespace LmbrCentral

@ -349,7 +349,7 @@ namespace LmbrCentral
const AZ::Vector3& src, const AZ::Vector3& dir, float& distance)
{
const auto rayIntersectData = IntersectSpline(m_cachedUniformScaleTransform, src, dir, *m_splineCommon.m_spline);
distance = rayIntersectData.m_rayDistance * m_cachedUniformScaleTransform.GetScale().GetMaxElement();
distance = rayIntersectData.m_rayDistance * m_cachedUniformScaleTransform.GetUniformScale();
AzFramework::CameraState cameraState;
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(

@ -136,7 +136,7 @@ namespace LmbrCentral
[[maybe_unused]] const AZ::Vector3& currentNonUniformScale)
{
m_position = currentTransform.GetTranslation();
m_radius = configuration.m_radius * currentTransform.GetScale().GetMaxElement();
m_radius = configuration.m_radius * currentTransform.GetUniformScale();
}
void DrawSphereShape(

@ -685,7 +685,7 @@ namespace PhysX
// Let each collider decide how to scale itself, so extract the scale here.
AZ::Transform entityWorldTransformWithoutScale = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(entityWorldTransformWithoutScale, m_entityId, &AZ::TransformInterface::GetWorldTM);
entityWorldTransformWithoutScale.ExtractScale();
entityWorldTransformWithoutScale.ExtractUniformScale();
auto* physXDebug = AZ::Interface<Debug::PhysXDebugInterface>::Get();
if (physXDebug == nullptr)

@ -89,7 +89,7 @@ namespace PhysX
AZ::Transform worldTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(
worldTransform, m_entityComponentId.GetEntityId(), &AZ::TransformInterface::GetWorldTM);
worldTransform.ExtractScale();
worldTransform.ExtractUniformScale();
AZ::Transform localTransform = AZ::Transform::CreateIdentity();
EditorJointRequestBus::EventResult(

@ -603,7 +603,7 @@ namespace PhysX
}
AZ::Transform colliderTransform = GetWorldTM();
colliderTransform.ExtractScale();
colliderTransform.ExtractUniformScale();
AzPhysics::StaticRigidBodyConfiguration configuration;
configuration.m_orientation = colliderTransform.GetRotation();
configuration.m_position = colliderTransform.GetTranslation();

@ -365,7 +365,7 @@ namespace PhysX
}
AZ::Transform colliderTransform = GetWorldTM();
colliderTransform.ExtractScale();
colliderTransform.ExtractUniformScale();
AzPhysics::RigidBodyConfiguration configuration = m_config;
configuration.m_orientation = colliderTransform.GetRotation();

@ -205,7 +205,7 @@ namespace PhysX
}
AZ::Transform transform = GetWorldTM();
transform.ExtractScale();
transform.ExtractUniformScale();
const size_t numPoints = m_geometryCache.m_cachedSamplePoints.size();
for (size_t pointIndex = 0; pointIndex < numPoints; ++pointIndex)
{

@ -196,7 +196,7 @@ namespace PhysX
AZ::Transform::CreateFromQuaternionAndTranslation(colliderConfiguration.m_rotation, colliderConfiguration.m_position);
AZ::Transform shapeTransform = *m_transform;
shapeTransform.ExtractScale();
shapeTransform.ExtractUniformScale();
shapeTransform = existingTransform * shapeTransform;

@ -718,7 +718,7 @@ namespace PhysX
const float boundsInflationFactor = 1.0f;
AZ::Transform overallTransformNoScale = GetColliderWorldTransform(worldTransform,
colliderConfiguration.m_position, colliderConfiguration.m_rotation);
overallTransformNoScale.ExtractScale();
overallTransformNoScale.ExtractUniformScale();
const physx::PxBounds3 bounds = physx::PxGeometryQuery::getWorldBounds(geometryHolder.any(),
PxMathConvert(overallTransformNoScale),
boundsInflationFactor);
@ -1378,7 +1378,7 @@ namespace PhysX
AZ::TransformBus::EventResult(worldTransformWithoutScale
, entityId
, &AZ::TransformInterface::GetWorldTM);
worldTransformWithoutScale.ExtractScale();
worldTransformWithoutScale.ExtractUniformScale();
return worldTransformWithoutScale;
}
@ -1386,10 +1386,10 @@ namespace PhysX
const AZ::Transform& entityWorldTransform)
{
AZ::Transform jointWorldTransformWithoutScale = jointWorldTransform;
jointWorldTransformWithoutScale.ExtractScale();
jointWorldTransformWithoutScale.ExtractUniformScale();
AZ::Transform entityWorldTransformWithoutScale = entityWorldTransform;
entityWorldTransformWithoutScale.ExtractScale();
entityWorldTransformWithoutScale.ExtractUniformScale();
AZ::Transform entityWorldTransformInverse = entityWorldTransformWithoutScale.GetInverse();
return entityWorldTransformInverse * jointWorldTransformWithoutScale;
@ -1399,10 +1399,10 @@ namespace PhysX
const AZ::Transform& entityWorldTransform)
{
AZ::Transform jointLocalTransformWithoutScale = jointLocalTransform;
jointLocalTransformWithoutScale.ExtractScale();
jointLocalTransformWithoutScale.ExtractUniformScale();
AZ::Transform entityWorldTransformWithoutScale = entityWorldTransform;
entityWorldTransformWithoutScale.ExtractScale();
entityWorldTransformWithoutScale.ExtractUniformScale();
return entityWorldTransformWithoutScale * jointLocalTransformWithoutScale;
}

@ -139,7 +139,7 @@ namespace WhiteBox
{
const AZ::Transform worldTransformWithoutScale = [worldTransform = world]() mutable
{
worldTransform.SetScale(AZ::Vector3::CreateOne());
worldTransform.SetUniformScale(1.0f);
return worldTransform;
}();

@ -73,7 +73,7 @@ namespace WhiteBox
const AZ::Transform spaceFromLocal = localFromSpace.GetInverse();
const AZ::Vector3 spacePosition = spaceFromLocal.TransformPoint(localPosition);
const AZ::Vector3 spaceScaledPosition =
AZ::Transform::CreateScale(AZ::Vector3(scale)).TransformPoint(spacePosition);
AZ::Transform::CreateUniformScale(scale).TransformPoint(spacePosition);
return localFromSpace.TransformPoint(spaceScaledPosition);
}

Loading…
Cancel
Save